# Find\_by\_sql

**URL:** <https://www.ruby-forum.com/t/find-by-sql/194642>\
**Category:** Rails\
**Created:** [September 8, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642 "2010-09-08T13:10:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/1 "2010-09-08T13:10:06Z")

</div>

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.

–  
With Regards  
Palani Kannan. K  
Office: +49-531-2616-226  
Mobile: +4917647098166

---

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 1:13pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/2 "2010-09-08T13:13:36Z")

</div>

Hi,

## You can pass the variable as params to your controller .

Regards,  
Amit K.

---

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 1:32pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/3 "2010-09-08T13:32:20Z")

</div>

On Sep 8, 12:08 pm, PalaniKannan K [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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

---

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 1:41pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/4 "2010-09-08T13:41:42Z")

</div>

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.

On 8 September 2010 13:16, Frederick C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > Office: +49-531-2616-226  
> > [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
With Regards  
Palani Kannan. K  
Office: +49-531-2616-226  
Mobile: +4917647098166

---

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 1:45pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/5 "2010-09-08T13:45:48Z")

</div>

## Please got through this tutorial [Ruby Tutorial](http://www.tutorialspoint.com/ruby/index.htm)

Regards,  
Amit K.

---

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 3:56pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/6 "2010-09-08T15:56:59Z")

</div>

Great!

---

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 3:49pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/7 "2010-09-08T15:49:21Z")

</div>

Hi,

Thanks to both Amit and Frederick, It works…

On 8 September 2010 13:44, Amit K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > model and view. I am a new bee.
> > 
> > > controller.
> > > 
> > > > 
> > > 
> > > To unsubscribe from this group, send email to  
> > > Palani Kannan. K  
> > > For more options, visit this group at  
> > > For more options, visit this group at  
> > > [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
With Regards  
Palani Kannan. K  
Office: +49-531-2616-226  
Mobile: +4917647098166

---

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 6:40pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/8 "2010-09-08T18:40:57Z")

</div>

Hi brito,

I used “find” by the way mr.Frederick adviced. i never used params in  
sql  
sentence. thank you for your intimation.  
On 8 September 2010 17:50, radhames brito [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > > Amit K.
> > > > 
> > > > > Hi Frederick,
> > > > > 
> > > > > > > Office: +49-531-2616-226  
> > > > > > > For more options, visit this group at
> > > 
> > > You received this message because you are subscribed to the Google G.  
> > > You received this message because you are subscribed to the Google G.  
> > > You received this message because you are subscribed to the Google G.  
> > > “Ruby on Rails: Talk” group.  
> > > To post to this group, send email to removed\_email\_address@domain.invalid.  
> > > To unsubscribe from this group, send email to  
> > > removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > > .  
> > > For more options, visit this group at  
> > > [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
With Regards  
Palani Kannan. K  
Office: +49-531-2616-226  
Mobile: +4917647098166

---

<div class="post-metadata">

**Author:** ![PalaniKannan\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PalaniKannan\_K](https://www.ruby-forum.com/u/PalaniKannan_K)\
**Post date:** [September 8, 2010, 5:57pm UTC](https://www.ruby-forum.com/t/find-by-sql/194642/9 "2010-09-08T17:57:02Z")

</div>

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