Displaying 3 results from an estimated 3 matches for "cuisine_id".
2006 Mar 14
3
Help doing find - look for nonempty habtm
...model, with a habtm. One thing I
want to do is find all the cuisines that have at least one restaurant
associated with them. Right now I''m using the following SQL query:
SELECT DISTINCT(cuisines.*) FROM cuisines, restaurants,
cuisines_restaurants WHERE cuisines.id =
cuisines_restaurants.cuisine_id AND restaurants.id =
cuisines_restaurants.restaurant_id AND restaurants.approved_at IS NOT
NULL
That''s working fine. I''d really like to make this a pure AR thing
though so I can use the rest of the AR options. Any tips on how to
make it happen? I''m using Rails 1.0, bu...
2006 Jul 09
1
Quick Question
I have this method in a controller
def sort_by_cuisine
#@restaurants = Restaurant.find(:all, :conditions => ["cuisine_id =
:id", params], :order => params[:sort])
@cuisines = Cuisine.find_all
end
And I want to put the bulk of it in the model, but still call it from
the controller. How can I do this? I''m fairly new to Ruby on Rails and
I''ve tried using local variables but this isn...
2006 Jul 31
9
Multiple Pagination
...ge => 2
@cuisines = Cuisine.find_all
rescue
redirect_to :action => :index
end
end
# sort by cuisine
def sort_by_cuisine
begin
@restaurant_pages, @restaurants = paginate :restaurants,
:conditions => [
"cuisine_id = :id", params ],
:order => (params[
:sort ] || "name"),
:per_page => 2
@cuisines = Cuisine.find_all
rescue
redirect_to :action => :sort_by_cuisine
end
en...