Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Jon Moss
1,150 PointsForm & URL Parameters
Hi, I am trying to use URL parameters as well as the Rails form fields...
Controller:
def new
@entry = Entry.new(name: params[:name])
end
def create
@entry = Entry.new(entry_params)
if @entry.save
redirect_to @entry, notice: 'Entry was successfully created.'
else
render :new
end
end
EX: Entry model has entry_type:string, so --> domain.com/entries/new?name=test
How do I include entry_params and (name: params[:name]) in the create action?
1 Answer

Chris Rennie
5,379 PointsWhat does your form look like? Are you using form_for ? <%= form_for(@entry) do |f| %>
if so then you should be able to do this: @entry = Entry.new( params[:entry])
Chris
Kenan Memis
47,314 PointsKenan Memis
47,314 PointsHi,
You are saying you're model has an attribute entry_type:string but I did not understand what do you want to do with :name?
Could you be more specific about the name parameter? What do you exactly want to do with it?