search for: user_role

Displaying 17 results from an estimated 17 matches for "user_role".

Did you mean: user_roles
2005 Oct 11
4
Searching an attribute in a hmabtm relationship
...curity using the login generator in a simple app so that I have a user table, a roles table, and a join between them (roles_users). All works as expected. I now need to check if a user has a specific role, but my approach is off somehow. Here''s what I''ve tried thusfar: user_roles = @session[:user].roles user_roles.find { |r| r.name == "officer"} When this executes, I get "can''t locate Role without ID...". What I *thought* I was doing was searching an array (user_roles) for a value, but this seems to imply that I''ve doing a d...
2007 Aug 10
1
How to spec a model method
Still new to Specs... How do I create a spec to test a model method? Specifically, here is my spec: #testing model describe User do it "should have many user roles" do User.reflect_on_association(:user_roles).should_not be_nil end it "should have many roles though user roles" do User.reflect_on_association(:roles).should_not be_nil end it "should know what role it has" do #User.should end end The last spec is incomplete... basically, I will want the code to be...
2010 Jun 03
2
creating fixtures for has_many :through
...s.com/videos/081_fixtures_in_rails_2.mov ... but that''s for HABTM relationships. I''ve read: http://www.ruby-forum.com/topic/145676 but that ultimately doesn''t answer any question. So with no further ado: ==== The models: class User < ActiveRecord::Base has_many :user_roles, :dependent => :destroy has_many :roles, :through => :user_roles end class Role < ActiveRecord::Base has_many :user_roles, :dependent => :destroy has_many :users, :through => :user_roles end class UserRole < ActiveRecord::Base belongs_to :role belongs_to :user end ====...
2010 Oct 27
0
Help with routes
Switching our routes file from Rails2 to Rails3 DSl uncovered an odd situation, of my own making, but I am having some difficultly imagining how to fix it. Basically I have a commonplace: user -> user_role (clearance) <- role type arrangement where: User has_many :roles, :through => :clearances has_many :clearances Clearance belongs_to :role belongs_to :user and Role has_many :users, :through => :clearances has_many :clearances What I am trying to do is to link through n...
2011 Mar 01
0
Association data within a fields_for
How do I use association data from within a fields_for? I''ve got a has many through relationship between users, schools and schools_users. A user can have multiple schools and a school has multiple users. In schools_users there is a user_role field in addition to the common user_id and school_id. In the show view I have: <% @school.schools_users.each do |user| %> <tr><td><%= user.user.first_name %> <%= user.user.last_name %></td><td><%= user.user_role %></td></tr> <% end...
2011 Jan 02
3
how to has_many User::Role?
So I just found out that I sort my models via folders and am starting a new project to mess around with this some. So I started working on can-can, but am at a lost on how to do "has_many :user_roles" -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this g...
2006 Aug 03
2
inserting values in two tables at one button click
...roblem is: i have to insert values into two tables at one submit. i am using mysql as db. i have created two tables which has one to one reelation ship. once i enter name and email address and role. name and emailaddress has to be inserted in users table. with that id role is to be inserted in user_roles table.can any help me in this. -- Posted via http://www.ruby-forum.com/.
2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
..."."id", "people"."first", "people"."last", "people"."entity_id", "people"."user_id" FROM "people" WHERE ("people".user_id = 1061) LIMIT 1 UserRole Load (6.1ms) SELECT DISTINCT "user_roles".role_name FROM "user_roles" WHERE ("user_roles".user_id = 1061) SQL (1.5ms) UPDATE "users" SET "emails_delivery_period" = ''--- :daily_logs: :immediately :homework: :immediately :events: :immediately :signups: :immediately :polls: :immediate...
2010 Jan 21
2
nested forms and attr_accessable
...;, "description"=>"Just a test", "effective_from"=>"2009-01-01"}, {"role_id"=>"178", "effective_from"=>"2010-01-21 00:00:00 -0500", "user_id"=>"146"}], "controller"=>"user_roles"} But this: if @user.update_attributes!(params[:user]) neither raises an error nor updates the rows. I have tried this with and without the attr_accessible initializer and the results are the same ether way. I read that this should work with nested rows but I cannot determine what I...
2006 Aug 17
6
NameError in AdminController#index building scaffold
...----+ | user_id | int(11) | NO | PRI | NULL | auto_increment | | user_login | varchar(50) | NO | | | | | user_firstname | varchar(50) | NO | | | | | user_lastname | varchar(50) | NO | | | | | user_role | varchar(50) | NO | | | | +----------------+-------------+------+-----+---------+----------------+ 5 rows in set (0.18 sec) I am also connecting to Subversion on a linux system as my Repo. When I start my server I am able to view several other controllers. I s...
2007 Aug 15
10
Objects in Session State Revisited
Hi Folks, I''m still a bit confused about the issue of storing "complex" objects in session state rather than storing simple objects. It''s my understanding that everything is an object in Ruby. If my understanding is correct, then storing a string or an integer in session means storing an object. It would seem then that the problem of storing objects in session is a
2007 Jan 11
4
collection_select - how to set selected options?
In a form, I am trying to use collection_select with multiple=true, like so: collection_select(:user, :roles, Role.find(:all), ''id'', ''name'', {}, :multiple => true) %> My multiple select box is rendered fine, but... I want the select to have the current role options for the user pre-selected when I view it. So if there are five roles in the database and
2006 Jul 07
4
need help with some ugly code - is there a better way?
Hi, In my user_controller.rb, I have the following method, which is supposed to send the user to their profile, dependng on what "role" they are (the roles correspond to the other controllers: venue, band, fan): def login if request.post? if session[:user_id] = User.authenticate(params[:user][:login], params[:user][:password]) flash[:message] =
2012 Apr 03
4
one master table to hold symbols: good or bad idea?
...gt; true do |t| t.string "name" end create_table "roles", :force => true do |t| t.string "name" end ... etc ... These moels are always joined through a has_many_through relation to some other object (e.g. User :has_many :roles, :through => :user_roles), and the names are treated effectively as constant symbols. So I''m thinking of consolidating these models into a single one: create_table :symbols, :force => true do |t| t.string :name end add_index :symbols, :name, :unique=>true class Util::Symbol < ActiveRecord:...
2006 Mar 29
0
Join Finder Question (ActiveRecord)
Hi I have a many-to-many relationship between users and roles class User << ActiveRecord::Base has_and_belongs_to_many :roles end class Role << ActiveRecord::Base ... end There is an user_roles table for the many-to-many and all works as expected. Role has an attribute (attr_x). I want to find the Users that have a Role with attr_x == some val, in one find. Is there any simple way to specify in the find that Person.role[].attr_x == some val? Thanks very much. Fernando. -- Posted...
2007 May 05
10
have_one and have_present
>Comment By: Luis Lavena (luislavena) > Date: 2007-05-04 23:37 > describe "An Asset" do > before(:each) do > @asset = Asset.new > end > > it { @asset.should have_one(:attachment) } > it { @asset.should have_present(:something) } > end Food for thought on these. I like have_one a lot. It speaks to me as a Rails developer and I think it speaks to
2010 Feb 16
0
Strange routing(?) Issue
...les"} PUT / roles/:id(.:format) {:action=>"update", :controller=>"roles"} DELETE / roles/:id(.:format) {:action=>"destroy", :controller=>"roles"} user_roles GET /users/:user_id/ roles(.:format) {:action=>"index", :controller=>"roles"} POST /users/:user_id/ roles(.:format) {:action=>"create", :controller=>"roles"} new_user_role GET /users...