Displaying 2 results from an estimated 2 matches for "user_interests".
2010 Apr 02
6
App_Controller and partial issues with has_many through
...st has_many users through interests
has_many interests, dependent destroy
Post has_many interests
Interest belongs to Post
Interest belongs to User
Application_Controller is as follows:
class ApplicationController < ActionController::Base
before_filter :login_from_cookie
before_filter :find_user_interests
helper :all # include all helpers, all the time
session :session_key => ''_blah_session''
include AuthenticatedSystem
def find_user_interests
@user_interests = current_user ? current_user.interests : []
true
end
end
Application.html.erb has as follows:
<%...
2006 May 10
1
Validates_uniqueness_of multiple field combo?
Hello,
I am new to Ruby on rails and this is therefore probably trivial. Lets
say I have 3 tables - users[id,name, age, ...],
interests[id,name,description, ...], and finally a table
user_interests[id,user_id,interest_id] to link a user to a set of
interests. Now there is no problem to put validates_uniqueness_of :name
in the user-model to ensure that I only have one Lenny, but how do I
validate the uniqueness of Lenny''s interests in the user_interest-table?
Ie, is there a method...