Ruby on Rails: Replacing the “LIKE” part of the SQL query with Ruby code


HOME ยป Databases

In my application I have a "LIKE" SQL query that is something like...


Item.where("name LIKE ?", "%"+params[:q]+"%").all

But I want to hit the db only 1x (at application start-up), since the number of Items is huge, and load this generic part...


Item.all

...into memory (a global variable), so I can later reuse its content throughout the app, in different cases, and refined with some case-specific Ruby code (see the "LIKE" part).


What's the speediest way to do such "filtering" with Ruby?


Related to : Ruby on Rails: Replacing the “LIKE” part of the SQL query with Ruby code
Does the hoster has to support “Ruby on Rails” or “just Ruby” to run Rails?
Databases

Does the hoster have to support "Ruby on Rails" or "just Ruby" to run Rails?


I know mainly PHP and ask myself if "Ruby on Rails" behaves to Ruby ... like "Zend Framework" to PHP: just a bunch of PHP files I can copy in my project folder and my hoster only needs to support PHP.


I ask as my host only supports Ruby (but not Rails). If I couild just copy rails over sftp within the project, I would like to give it a try.


Easiest way to “goto source code” for Ruby/Rails
Databases

As a Ruby/Rails non-pro, I often want to check out the code for a rails method to see how it's implemented...


For example, I was using "form_for", and I wanted to check out the code to see how it works. The slightly lame way I did this was to just google "rails form_for" which takes me to http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html, where I can view the source for form_for.


How do rails/ruby pro's accomplish a similar task? Is there a simple way (without using IDEs) that you can quickly dig this out? Or is it a case of over time learning where stuff is located and find/grep-ing it?


Cheers


RUBY ON RAILS - “msvcrt-ruby18.dll was not found” with Ruby
Databases

i am using:
windows 7
rails 3.0


whenever i try to run rake db:migrate. i get the following error in popup...


This application has failed to start because msvcrt-ruby18.dll was not found. Re-installing the application may fix the problem.


need help here..
thnx..


Ruby on Rails: Replacing the “LIKE” part of the SQL query with Ruby code
Databases

In my application I have a "LIKE" SQL query that is something like...


Item.where("name LIKE ?", "%"+params[:q]+"%").all

But I want to hit the db only 1x (at application start-up), since the number of Items is huge, and load this generic part...


Item.all

...into memory (a global variable), so I can later reuse its content throughout the app, in different cases, and refined with some case-specific Ruby code (see the "LIKE" part).


What's the speediest way to do such "filtering" with Ruby?


When you run “rails server” how do you get the ruby version to match what you see with “ruby -v”?
Databases

I can't seem to get my version of ruby when running "rails server" to be the same as the one in terminal. If I run commands like ruby -v I get 1.9.3 which is the version that I want to use. But I get 1.8.7 when I use rails server. Any idea how I get get my local server to leverage 1.9.3? I am using a Mac with Lion.


CHRISs-MacBook-Pro:test_app chrisrothstein$ rvm list
rvm rubies
=* ruby-1.9.3-p125 [ x86_64 ]
# => - current
# =* - current && default
# * - default
CHRISs-MacBook-Pro:test_app chrisrothstein$ ruby -v
ruby 1.9.3p125 (2012-02-16 rev
where in the Ruby or Ruby on Rails API doco is the Date “dweek” method?
Databases

where in the Ruby or Ruby on Rails API doco is the Date "dweek" method?


Example of usage:


Loading development environment (Rails 3.2.1)
1.9.3p0 :001 > d = Time.now.to_date
=> Sun, 04 Mar 2012
1.9.3p0 :002 > d.wday
=> 0


Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .