find_by_sql

Hi,

I am using
find_by_sql (“SELECT * FROM taxas WHERE taxon_id = ‘39’”) in controller.

Instead of ‘39’… I need to get variable from the user through view.rhtml.

Kindly help me on this scripting.

Hi,

You can pass the variable as params to your controller .

Hi,

I am using
find_by_sql ("SELECT * FROM taxas WHERE taxon_id = '39'") in controller.

Instead of '39'... I need to get variable from the user through view.rhtml.

There's no reason to use find_by_sql here - a regular find with
conditions or a dynamic finder (find_by_taxon_id) should be fine.

Fred

Hi Amit,

Thank you for reply, I dont know the method to apply params, kinldy give me some tutorial to apply params and modifications in controller, model and view for applying param. I am a new bee.

Hi Frederick,

Thank you for reply, when i use find_by_taxon_id, I am unable to apply it directly with constant and i need to apply through param. I dnt know the method to apply param. If you know the method to apply param in this case kindly give me tutorial or reference which for modifications in controller, model and view. I am a new bee.

Please got through this tutorial http://www.tutorialspoint.com/ruby/index.htm

Hi,

Thanks to both Amit and Frederick, It works…

Great!

one note never pass the params hash to a sql sentence NEVER.

Hi brito,

I used “find” by the way mr.Frederick adviced. i never used params in sql sentence. thank you for your intimation.