similar to: Coding conventions (mostly AR)

Displaying 20 results from an estimated 1000 matches similar to: "Coding conventions (mostly AR)"

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
2007 Dec 09
4
Help on drying code
Hi all, Currently I''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 <<
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
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 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
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
2006 Jan 04
0
Re: DB Modelling the Rails way - solution by Chris Hall
Hi Chris, Yesterday you kindly submitted an answer to my question on modelling many to many relationships. I''ve briefly tried the proposed solution but so far with no luck. Before I get too involved - I''d like to know if mapping three way :join_tables is "legal" in a Rails sense. I only ask since you put (untested) in your mail and I can''t find any docs on
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
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,
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:
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 =>
2006 Jan 07
4
To Chris Hall - Re: DB Modelling the Rails way - Opinions??
Chris, Finally got time to fully play with your suggestions. Had to re-code a bit of stuff but the concept works - just like a bought one :~). Many thanks for the solution, Kind Regards, Eric. For those curious - here''s what it was about; On Monday 02 January 2006 02:10, Eric Sloane tried to type something like: > Hi, > I''m trying to figure the most efficient way to
2006 Apr 07
0
HABTM query return all results
I have a role-based authorization system exactly like the one from Rails Recepies. I am looking to return all rights however in my view I want to highlight the rights that are associated with the currently selected role (passed in through @params[:id]). Schema: create_table "rights", :force => true do |t| t.column "name", :string t.column "controller",
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 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
1998 Jul 01
0
"Coding conventions" for R: Use TRUE & FALSE, and not T & F
The reason being a design decision of a while ago that "T" and "F" shouldn't be reserved words in R as they are in S-plus. Hence, T & F are just variables being set to TRUE and FALSE respectively; they *can* be overwritten by the user which is very useful e.g., when you do mydat <- read.table(file, header =TRUE) and the file has variable names "T" or
2006 Mar 07
6
fcgi dispatcher crashing
I''m trying to set deploy an app on apache2 with the fcgid module, but can''t seem to get anywhere. Things work fine with cgi, but when i switch to fcgi, i''m stuck with a ''503: Service Temporarily Unavailable''. There''s no error being logged anywhere, afaik. Trying to run dispatch.fcgi from the shell doesn''t work either. It bombs out,
2006 Jul 25
0
Errors logged but not returned to browser, WEBrick hangs
An app I''ve been developing has been chugging along nicely, but around the time I added a new join model a couple of commits ago, my development environment has been acting screwy. 1. When there''s an error, the error messages and tracebacks are not being returned to the browser. The browser keeps the connection alive indefinitely. 2. Stopping the request from the browser
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