Displaying 20 results from an estimated 55 matches for "role_ids".
Did you mean:
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
wh...
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
2005 Nov 16
1
HABTM: deleting records based on attributes
Hello All,
I am new to ROR, and can''t seem to get HABTM to cooperate entirely...
however I might be abusing it! Before I try a different strategy I
thought I''d ask here and see if I''m missing something simple.
So say Projects and Companies are related. Projects can have multiple
Companies, and Companies can be on multiple Projects. But, the same
Company can also
2008 Apr 03
2
Change the value stored in inheritance_column
I have been struggling for quite sometime with this.
Is there any way to configure the Model to store user defined 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
2010 Feb 16
0
Strange routing(?) Issue
I have a Model event and the following two lines in routes.rb
1 - map.connect "events/:action", :controller => ''events'', :action => /
[a-z_]+/i
2 - map.resources :events, :has_many => :comments, :has_one
=> :address #, :collection => {:mapit => :get}
I have #1 so that I can call custom actions from a link_to_remote link
from my index page t0 update a
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 =>
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 P...
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
2010 Jan 21
2
nested forms and attr_accessable
Rails 2.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
2006 Aug 07
0
question/problem with habtm and "include?"
I have what I feel is a standard habtm association to manage
user/roles/permissions. However, I''m having a small problem wondering
why ".include?" isn''t working like I thought it should.
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'')
2006 Jun 09
1
finder_sql issue with has_many :through
I have an inner join query that Action Record can''t seem to pull off
conventionally, so I''m trying to use :finder_sql to utilize an sql query
that works beautifully in SQL. The problem is, when I try to call the
method, I get the following:
private method `gsub'' called for #<Array:0x267de04>
Here is my has_many code:
has_many :mod_privileges,
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 =>
2006 Sep 05
0
rake craziness with Migrate as a dependency
Hi everyone,
For one of our projects we have a need to deploy and maintain a demo.
As a result I''ve attempted to setup a set of rake tasks for the job.
My goal is have one rake task called "deploy_demo" which purges the
database, migrates to the current schema, and loads the db from a set
of fixture files in a specified location.
I''ve written two new tasks the perform
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
2012 Sep 02
1
to_model
There''s a number of calls in the Rails source to convert_to_model,
which takes an activerecord object instance:
convert_to_model(object)
Here''s the thing. All convert_to_model does is calls to_model, which
returns self (the ActiveModel instance).
Am I missing something here? Why call a method that returns the same
thing?
@user
=> #<User id: 3, name:
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
Hi all, I am trying to reproduce rails 3.2 behaviour with fields_for and
nested attributes.
class ControllerAction < ActiveRecord::Base
has_many :interactions, dependent: :destroy
has_many :roles, through: :interactions
scope :controllers, lambda {|name| where("controller_name_id = ?",
name)}
scope :actions, lambda {|name| where("action_name_id =
2006 Aug 18
9
Rails is doing what I want - but I don''t understand how.
Hi guys, I have the strangest thing happening. The funny part is its
doing exactly what I want to do, I just don''t understand how.
Basically here is my model.
class Role < ActiveRecord::Base
has_and_belongs_to_many :users
has_and_belongs_to_many :rights
def self.names
names = Array.new()
for role in Role.find :all
names << role.name
end
return