Hi Janna,

First, you shouldn't be calling Channel.find(:all,  :order => 'channel
ASC',  :conditions => ['deleted=0']).collect {|p| [ p.channel, p.id ]}

I'd add a named scope to the Channel model like so:

  named_scope :not_deleted, :conditions => {:deleted =>
false }, :order => 'channel ASC'

And then in the controller:
@channels = Channel.not_deleted

Then in your view:
<%= f.select :channel_id, @channels %>

The standard here would be to create the new Ups in a method called
create. By using form_for on a new record rails will automatically
know to post to an action called create so, unless you have a good
reason not to, I'd recommend calling your controller method "create"
and letting Rails behave the way it wants to.

which 'line feed' do you want to remove?

Gavin

http://handyrailstips.com

On Jun 24, 4:46 pm, JannaB <mistressja...@hotmail.com> wrote:
> I have a model ("Ups")  and a corresponding controller
> ("UpsController"). The Ups model has a link to my "channels" toble
> through channel_id
>
> Everything I am going to do in the given views for Ups have to do with
> using those ups from a selected channel. Thus, I am putting a partial
> at the top of the views, with a select box to choose the channels:
>
> <div id="uplognavlist">
> <% form_for :ups, :html => {:name => 'channelsform'},:url=>{ :action
> =>"newchannel", :controller =>"ups"} do |f| %>
>     <%= f.label :channel_id %>
>         <%= select("channel", "channel_id", Channel.find(:all,  :order =>
> 'channel ASC',  :conditions => ['deleted=0']).collect {|p|
> [ p.channel, p.id ]}, {:include_blank => true}) %>
>         <%= f.submit "Change" , :class=>'button' %>
> <% end %>
>         <%= links_for_uplog %>
> </div>
>
> My question is, within my UpsController.newchannel(), how do I access
> the calue of the channel_id that has been selected in the form
> submission?
>
> Incidentally, if you look at the erb code I put above, there is a line
> feed that gets inserted after the submit button, before the next
> section " links_for_uplog " within the div. How can I not have that?
>
> Thanks, Janna
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to