Gavin,

Thank you. But suppose I didn't use a named scope -- in that case, how
then could I refer to it in my controller? (though I will follow your
advice and use the named scope, I need to know the other way also).

Also, between:

  <%= f.submit "Change" , :class=>'button' %>
<% end %>
        <%= links_for_uplog %>

it seems a line feed occurs......the  <%= links_for_uplog %>  is not
immediately to the right as I would like it to be (in <%=
links_for_uplog %>,

the rendered html appears as (copying from firebug):
<div id="uplognavlist">
<form name="channelsform" method="post" action="/ups/newchannel">
<div style="margin: 0pt; padding: 0pt;">
<input type="hidden" value="Ty9TBUArgAPxtLuvGL48Sg1uYbzlZWmSJL2dsWuL
+YQ=" name="authenticity_token"/>
</div>
<label for="ups_channel_id">Channel</label>
<select id="channel_channel_id" onchange="document.channelsform.submit
();" name="channel[channel_id]">
<option value=""/>
<option value="1">ggriptest</option>
</select>
</form>
<a title="Non-Automatic Change Log" style="float: right;" href="/
audits/list?update=UpLogBody">Audit</a>
<a title="Add or Remove Associates" style="float: right;" href="/ups/
hotwire?update=UpLogBody">Hotwire</a>
<a title="Show Uplog" style="float: right;" href="/ups/uplog?
update=UpLogBody">Uplog</a>
</div>


It appears that after either </select> or </form> there is some kind
of a line feed in the display.

Can you please answer Me those two questions Gavin? Thank You, Janna

On Jun 24, 12:47 pm, Gavin <ga...@thinkersplayground.com> wrote:
> 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