Dr. Chocolate
Dr. Chocolate

Reputation: 2165

Is it possible to call parameters from a string in rails?

For example:

x = "Hi my name is params[:name]"

or

x= "Hi my name is params[:name] and my favorite color is params[:color]"

I want to use one controller for a whole bunch of simple text request/responses but they might have unpredictable parameters.

Upvotes: 0

Views: 56

Answers (1)

potashin
potashin

Reputation: 44581

You can interpolate variables in strings like this in ruby:

x = "Hi my name is #{params[:name]} and my favorite color is #{params[:color]}"

Upvotes: 1

Related Questions