Select in list.rhtml

i am new to ruby on rails, and this might be a simple one but i have
no idea what to do.
i need to put a select (_tag or whatever) into a list.rhtml and get
the selected value from this. Putting the select to the view works
fine. The displayed options are ok too, but i don’t know how to get
the selected option. What i have so far:

<% for calendar in @calendars %>

<%= link_to "#{calendar.person.account}", { :controller => 'person', :action => 'list', :person_id => calendar.person.id } %> <%= link_to "#{calendar.calendar_state.name}", { :controller => 'calendar', :action => 'list', :calendar_state_id => calendar.calendar_state } %> <%= select 'calendar', 'project_has_person_id', ProjectHasPerson.find(:all, :conditions => ["person_id = ?", calendar.person.id]).collect{ |p| [p.person.account + "@" + p.project.name, p.id]} %>

<% for column in Calendar.content_columns %>

<%=h calendar.send(column.name) %>
<% end %> <%= link_to 'assign', :action => 'assign', :id => calendar %> <% end %>

The calendar-entry has a column called project_has_person_id, but
whenever i try to access the parameter in the controller with
params[:project_has_person_id] the value will be nil.

Any help is appreciated!

Thanks

On Thu, Jul 24, 2008 at 8:04 AM, marco [email protected] wrote:

<%= link_to "#{calendar.person.account}", { :controller => <% for column in Calendar.content_columns %> <%=h calendar.send(column.name) %> <% end %> <%= link_to 'assign', :action => 'assign', :id => calendar %> <% end %>

The calendar-entry has a column called project_has_person_id, but
whenever i try to access the parameter in the controller with
params[:project_has_person_id] the value will be nil.

I suspect that the value is in
params[:calendar][:project_has_person_id].

The development log will show you all of the values of the params
object.

thank you for your reply.
i have tried your solution, but it didn’t work either.
is there really no way to pass a selected value coming from a
selection to a controller?

marco

Citando marco [email protected]:

<%= link_to "#{calendar.person.account}", { :controller => <% for column in Calendar.content_columns %>

Any help is appreciated!

You might be interessed in this article:
http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model

Sorry for my poor English.

HTH,

Davi V.

Hi macro,

Try to place your select statement inside a form tag instead of
link_to, only then it submits the selection to the controller.
Then you need to access the selection by params[:calendar]
[:project_has_person_id] as stated by Christopher.

Thanks,
Kiran.
http://kiran.gnufied.org

Thanks a lot Kiran!
That did exactly what i want.

marco