search for: role_id

Displaying 20 results from an estimated 55 matches for "role_id".

2007 Dec 09
4
Help on drying code
...;m having to do this: def self.authorized_roles(controller, action) specific = self.find_by_controller_and_action(controller, action) all_actions = self.find_by_controller_and_action(controller, ''*'') all_controllers = self.find_by_controller(''*'') role_ids = [] specific.each do |role_item| role_ids << role_item.role_id end all_actions.each do |role_item| role_ids << role_item.role_id end all_controllers.each do |role_item| role_ids << role_item.role_id end role_ids.flatten.uniq end w...
2006 Apr 15
6
view code regular expression
I''m lost on regular expressions to begin with... I''m trying to fix a value to one of 4 radio buttons as there will be value of either 1,2,3 or 4 in @roles_users... <TD><input type="radio" id="roles" name="case_managers[case_manager_name]" value="Case Manager Admin" <% if =~ @roles_users /1/ checked =
2006 Apr 10
6
Single Table Mapping
This is pretty simple, but I must be missing the obvious. I''ve got a table that''s similar to this: USERS: - id int - username varchar(64) - password varchar(64) - role_id int ROLES: - id int - description varchar(16) I''ve had no troubles doing has_many relationships at all. But I want to map the user.role directly to the role model automatically (which sounds like it should be really simple). Right now if I look at the user''s attributes the...
2005 Nov 16
1
HABTM: deleting records based on attributes
...s are related. Projects can have multiple Companies, and Companies can be on multiple Projects. But, the same Company can also be assigned multiple times to the same Project under different roles. This all works fine with something like this: @project.companies.push_with_attributes(company, :role_id => params[:role_id]) So I make 2 entries for a Company. One with the role of ''shipping'', and one with the role of ''distribution''. Now how do I remove only one of the entries? I can only seem to find ways to remove Companies from a Project based on comp...
2008 Apr 03
2
Change the value stored in inheritance_column
...ned value in the inheritance_column instead of the default value (which is class_name) The problem I have is like this: I have a User model and there are different models which inherit from this like Admin, Premium, Professional, etc. Each of these inherited models are identified by a field named role_id in the users table and it contains integer values for e.g. 1 for Admin, 2 for Premium, 3 for Professional and so on. I want to set this role_id field as the inheritance_column, which can be easily done by specifying :inheritance_column => "role_id" in the User Model. But how do I conf...
2010 Feb 16
0
Strange routing(?) Issue
...r_sessions/:id(.:format) {:action=>"update", :controller=>"user_sessions"} DELETE / user_sessions/:id(.:format) {:action=>"destroy", :controller=>"user_sessions"} role_users GET /roles/:role_id/ users(.:format) {:action=>"index", :controller=>"users"} POST /roles/:role_id/ users(.:format) {:action=>"create", :controller=>"users"} new_role_user GET /roles/:role_id/users/ new(.:f...
2009 Feb 17
3
Dynamic select box
Hi everyone, I have a problem. I want to display a different select box wether the current user is an admin or an user. So I thought I could do this in my view where my form is displayed : <p class="form-input"> <%= f.label(:role_id, ''Role:'') %> <% if (current_user.admin?) then collection_select(:user, :role_id, Role.find(:all, :order => "name desc"), :id, :name) else # Here I would code an another collection_select end %> </p> But It doesn''t work. Nothing...
2012 Nov 03
0
ids writer fields for HABTM relationship.
Hello forum readers, Let''s say i have two models: Person and Role (i replicated the problem with Post & Tag as well, as i thought the problem was linked to some application-specific rights problem, but it wasn''t). In Person, attr_accessible role_ids is declared, so it accepts an array of Role ids as an argument when creating / updating. If i fire up the rails console and just do: [code] Person.first.role_ids = [1, 2, 3] [/code] Everything works so far. Now from the web browser, when trying to update a specific person, i get: [code] Started...
2005 Dec 19
3
Is there a list of html_options for the FormOptionsHelper?
I''m looking for a way to select a default value from a select box, like this: select("user", "role_id", Role.find_all.collect {|r| [ r.name, r.id ] }, { :default_value => ''5'' } (of course, there is no ":default_value") If the form is being used on a ''create'' page, it should display a default in the select box. If the form is on the ''...
2010 Jan 21
2
nested forms and attr_accessable
...3.5 I am working on a nested form that assigns roles to users through a table called clearances. I have attr_acessable turned off globally in an initializer: ActiveRecord::Base.send(:attr_accessible, nil) I have this set in clearance.rb attr_accessible(:description, :effective_from, :role_id, :superceded_after, :user_id) And this is what params looks like after the submit button is selected: {"user"=>{"id"=>"146"}, "commit"=>"Commit Changes", "_method"=>"put", "action"=>"update...
2006 Aug 07
0
question/problem with habtm and "include?"
.... I''m attempting to use this to determine whether a user has access to a particular permission: if session[:user].role.permissions.include?(''Lead List'') do something end If I call session[:user].role.permissions.inspect I get this: [#"Lead List", "role_id"=>"1", "permission_id"=>"1", "id"=>"1"}>, #"Purchase Orders", "role_id"=>"1", "permission_id"=>"4", "id"=>"4"}>, #"Quotes", "role_id&...
2006 Jun 09
1
finder_sql issue with has_many :through
...#<Array:0x267de04> Here is my has_many code: has_many :mod_privileges, :finder_sql => [''SELECT assignments.* FROM assignments INNER JOIN permissions ON assignments.publisher_id = permissions.publisher_id WHERE permissions.user_id = #{current_user.id} AND (permissions.role_id = 3 OR (permissions.role_id = 4 and permissions.assignment_id = assignments.id))''] and a simple test bit I threw into the view: <%= debug(current_user.mod_privileges) %> I was using has_many :through, but there seemed to be no way to do an inner join on something other than th...
2006 Apr 10
0
Issue with session variables
I had (at one time) got this thing working but it doesnt'' seem to work any more. I am trying to display a specific user menu depending on the session variable. Here is what I have: <% for @role in @session[:user][:role] %> <% if @role.role_id == ''1'' %> <li><% link_to "Create Resource", :controller => "admin", :action => "new_resource" %></li> <li><% link_to "View New Resources", :controller => "admin&qu...
2006 Sep 05
0
rake craziness with Migrate as a dependency
...-> 0.0700s -- add_index("groups", ["parent_id"], {:name=>"groups_parent_id_index"}) -> 0.2010s -- create_table("groups_roles", {:force=>true, :id=>false}) -> 0.1000s -- add_index("groups_roles", ["group_id", "role_id"], {:name=>"groups_roles_all_index", :unique=>true}) -> 0.2200s -- add_index("groups_roles", ["role_id"], {:name=>"role_id"}) -> 0.2200s -- create_table("groups_users", {:force=>true, :id=>false}) -> 0.1010s --...
2008 Oct 10
2
Another "I'm I right" question...
I''m pretty sure that there''s a better way to do this: @roles = Role.find(:all) @selected_role = Role.find(@user.role_id) Can someone help me? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe...
2012 Sep 02
1
to_model
...ount: 1, current_sign_in_at: "2011-09-27 17:01:45", last_sign_in_at: "2011-09-27 17:01:45", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", created_at: "2011-09-12 16:55:30", updated_at: "2011-09-27 17:01:45", account_id: 1, role_id: 1, authentication_token: nil> @user.to_model => #<User id: 3, name: "dscdsf", email: "fgd-kX2TDLzHGmnQT0dZR+AlfA@public.gmane.org", encrypted_password: "", phone: "9544443456", address: "fvfdvf", reset_password_token: nil, reset_passwor...
2008 Mar 23
1
radio buttons - how to identify record using value?
I''m making a simple questionnaire app using RoR. I''ve got a model for Questions, a model for Answers, and a third model, Qa, for matching each question to five possible answers through foreign keys. So, each qa has a question and five answers , a1-a5, through belongs_to and a :foreign_key, and then a selected_answer field for specifying which answer was selected by the user. The
2006 Apr 15
8
Migrations - adding a new table and automatically creating records
I want to create table called roles and then populate it with some new records...This doesn''t work. Is there something I''m missing? Craig class AddRightsAndRolesTables < ActiveRecord::Migration def self.up create_table :roles do |t| t.column "name", :string end Role.reset_column_information Role.new :name => "Users Admin"
2013 Mar 24
5
Rails 4.0 has_many_through and fields_for
...|name| where("controller_name_id = ?", name)} scope :actions, lambda {|name| where("action_name_id = ?", name)} def initialized_interactions() # this is the key method [].tap do |o| Role.all.each do |r| if p = interactions.find { |p| p.role_id == r.id } o << p.tap { |p| p.enable ||= true } else o << Interaction.new(:role_id => r.id) end end end end end class Role < ActiveRecord::Base has_many :interactions end class Inter...
2006 Aug 18
9
Rails is doing what I want - but I don''t understand how.
...self.names names = Array.new() for role in Role.find :all names << role.name end return names end end migration file for reference: class CreateRoles < ActiveRecord::Migration def self.up create_table :roles_users, :id => false do |t| t.column "role_id", :integer t.column "user_id", :integer end create_table :roles do |t| t.column "name", :string end end def self.down drop_table :roles_users drop_table :roles end end As you can see I wrote a self.names methods so that I can easily call...