Get a value from previous page

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

As far as I understand your question you need to use the params hash-
like object.

Thanks, Ivan Povalyukhin

i need something like this

index.html.erb

<%= link_to 'cost', :action => 'search', :order => 'cost' %>

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

On 4 January 2011 00:56, Jose tomas R. [email protected] wrote:

@order = :order
I don’t understand what you are trying to do with the

Colin

On 4 January 2011 15:05, Jose tomas R. [email protected] wrote:

Please quote the previous message so your response can be understood.
Thanks.

what :S

In your previous message you have

<%= link_to 'cost', :action => 'search', [b]:order[/b] => 'cost'

and

@order = :order

I don’t understand what the and are for. It is not valid ruby.
I also don’t understand what question you are asking for help with.

Colin

what :S

On Jan 5, 1:03am, “Jose tomas R.” [email protected] wrote:

<%= link_to 'cost', :action => 'search', :order => 'cost' %>

cars_controller.rb

def search
@order = :order

take a look at what gets passed to your controller (in particular any
url query parameters are stored in params[:parameter_name]

Fred

i need something like this

index.html.erb

<%= link_to 'cost', :action => 'search', :order => 'cost' %>

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

I dont need @order ar params I need it as a value

On 5 January 2011 01:03, Jose tomas R. [email protected] wrote:

@order = :order
Look 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

On 6 January 2011 14:25, Jose tomas R. [email protected] 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

On 6 January 2011 21:34, Jose tomas R. [email protected] wrote:

@order = params[:order]
%>
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

Colin L. wrote in post #972821:

On 6 January 2011 14:25, Jose tomas R. [email protected] 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


<%= link_to 'cost', :action => 'search', :order_by => 'cost' %>

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?