how could i get a value from previus page? for example on EVENT show view i have <%= link_to ''New Message'', new_message_path( :event_id => @event.id) %> | and i need to get the event id on the new_message page to send it when creating the message -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
As far as I understand your question you need to use the params hash- like object. -- Thanks, Ivan Povalyukhin On Jan 2, 11:08 am, "Jose tomas R." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> how could i get a value from previus page? > for example > > on EVENT show view i have > > <%= link_to ''New Message'', new_message_path( :event_id => @event.id) %> > | > > and i need to get the event id on the new_message page to send it when > creating the message > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
i need something like this index.html.erb <th><%= link_to ''cost'', :action => ''search'', [b]:order[/b] => ''cost'' %></th> cars_controller.rb def search @order = [b]:order[/b] @cars = Car.paginate :page => params[:page], :order => @order respond_to do |format| format.html # index.html.erb format.xml { render :xml => @cars } end end -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 4 January 2011 00:56, Jose tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> i need something like this > > index.html.erb > > <th><%= link_to ''cost'', :action => ''search'', [b]:order[/b] => ''cost'' > %></th> > > cars_controller.rb > > def search > @order = [b]:order[/b]I don''t understand what you are trying to do with the [b] [/b] Colin> @cars = Car.paginate :page => params[:page], :order => @order > respond_to do |format| > format.html # index.html.erb > format.xml { render :xml => @cars } > end > end-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
what [b] [/b] :S -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 4 January 2011 15:05, Jose tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: Please quote the previous message so your response can be understood. Thanks.> what [b] [/b] :SIn your previous message you have> <th><%= link_to ''cost'', :action => ''search'', [b]:order[/b] => ''cost''and> @order = [b]:order[/b]I don''t understand what the [b] and [/b] are for. It is not valid ruby. I also don''t understand what question you are asking for help with. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
i need something like this index.html.erb <th><%= link_to ''cost'', :action => ''search'', :order => ''cost'' %></th> cars_controller.rb def search @order = :order @cars = Car.paginate :page => params[:page], :order => @order respond_to do |format| format.html # index.html.erb format.xml { render :xml => @cars } end end give a value from the view to the controller that way give value: :order => ''cost'' receive value: @order = :order but i dont know if it can be done like that -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 5, 1:03 am, "Jose tomas R." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > <th><%= link_to ''cost'', :action => ''search'', :order => ''cost'' > %></th> > > cars_controller.rb > > def search > @order = :ordertake a look at what gets passed to your controller (in particular any url query parameters are stored in params[:parameter_name] Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 5 January 2011 01:03, Jose tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> i need something like this > > index.html.erb > > <th><%= link_to ''cost'', :action => ''search'', :order => ''cost'' > %></th> > > cars_controller.rb > > def search > @order = :orderLook in the log file (development.log assuming you are in development mode) and you will see the parameters passed to the controller when you click the link. The parameters passed are then available in the params hash. So your :order variable should be available as params[:order]. I suggest you run through some tutorials to get an understanding of basic Rails operation. The one at railstutorial.org (available free online) is good. Also have a look at the Rails Guides. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I dont need @order ar params I need it as a value -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 January 2011 14:25, Jose tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: Please quote the previous message and insert your comments at the appropriate point, this makes it easier to follow the thread.> I dont need @order ar params I need it as a valueI have no idea what you mean by that. params[:order] *is* a value. You can say @order = params[:order] If I misunderstand your problem please try to explain again. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #972821:> On 6 January 2011 14:25, Jose tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > Please quote the previous message and insert your comments at the > appropriate point, this makes it easier to follow the thread. > >> I dont need @order ar params I need it as a value > > I have no idea what you mean by that. params[:order] *is* a value. > You can say > @order = params[:order] > > If I misunderstand your problem please try to explain again. > > ColinSo --- <th><%= link_to ''cost'', :action => ''search'', :order_by => ''cost'' %></th> --- def search @order = params[:order_by] @cars = Car.paginate :page => params[:page], :order => @order respond_to do |format| format.html # index.html.erb format.xml { render :xml => @cars } end end --- Will order my Cars by it cost? -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 January 2011 21:34, Jose tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #972821: >> On 6 January 2011 14:25, Jose tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> Please quote the previous message and insert your comments at the >> appropriate point, this makes it easier to follow the thread. >> >>> I dont need @order ar params I need it as a value >> >> I have no idea what you mean by that. params[:order] *is* a value. >> You can say >> @order = params[:order] >> >> If I misunderstand your problem please try to explain again. >> >> Colin > > So > > --- > > <th><%= link_to ''cost'', :action => ''search'', :order_by => ''cost'' > %></th> > > --- > > def search > @order = params[:order_by] > @cars = Car.paginate :page => params[:page], :order => @order > respond_to do |format| > format.html # index.html.erb > format.xml { render :xml => @cars } > end > end > > --- > > Will order my Cars by it cost?You do not need me to answer that, your automated tests will tell you whether it does or not. However that is a horrible way to do it. Firstly a small point, the variable @order can just be order, unless you want the variable to be accessible in the view. Secondly, however, imagine what would happen if someone sends an http request with an SQL snippet in :order. That will get inserted into the SQL of the find and could wreck your database. A better way would be to test the value of params[:order] for a set of valid values and use the appropriate order setting in the call to paginate. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.