Displaying 20 results from an estimated 2000 matches similar to: "HABTM query return all results"
2006 Dec 08
19
HABTM join table quirk
I''ve been bringing up a good basica framework for applications at work.
To give decent security I''ve been implementing the Rails Recipie for
Authorization of function calls modeled on the book''s implementation.
(Changes for our environment were added..but are minor.)
Since I initially let Rails create the join table between two data
tables with a HABTM relationship....I
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 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"
2006 Apr 06
1
drop down menu - getting @params[:id] value.
I am looking to get my option drop down list to populate from a model.
In my controller i''m using:
@roles = Role.find(:all, :order => "name")
in my view I have:
<%= collection_select(:id, :name, @roles, :id, :name) %> role <%=
submit_tag("Go") %>
I cannot get just the id of the selected option. If i inspect the params
I get:
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
Hi.
I have a couple of best practices questions regarding polymorphic
associations, naming join tables and user permissions.
Currently I have implemented the user authentication model from the
rails recipes book. Basically it goes something like this:
MODEL CLASSES:
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
end
class Role < ActiveRecord::Base
2006 Apr 27
7
Role Based Authorization recipe implementation?
i got the rails recipes book, i have now an auth system for users
without problems, now i want to made a role based acces for my app, im
following the "Role Based Authorization" recipe of the book but i cant
make it to work even when the tables created and correctly added data
manually definig the roles and rights. als i dont know how to define a
right for use all the actions in a
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
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'')
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 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
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 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
2006 May 23
2
HABTM for Dummies Question
Taking time off from programming is always painful :-).
I have the following Models:
====
class Tag < ActiveRecord::Base
has_and_belongs_to_many :problems
end
class Problem < ActiveRecord::Base
belongs_to :user
has_and_belongs_to_many :tags
end
====
And the following migrations:
====
create_table "problems" do |t|
t.column "user_id", :integer
2006 Jun 20
0
habtm has_many through and foreign keys
I have two models
Role and Task
..and a join table/model RoleTask
Now both roles and tasks have id as a primary key and name which is a
unique identifier
I want the join table to hold role_id and task_name
I''ve tried using habtm with foreign key and association foreign keys set
up and I''ve tried using has_many :through
..but they all seem to someone want to work with the
2007 Oct 22
1
self-referential habtm: why are my keys null?
I''m trying to set up a directional self-referential HABTM to represent
an arbitrary semi-hierarchical structure; it works for any data
prepopulated into the db, but when I try to create a new relationship,
I just get NULLs in both key columns (or 0''s if I turn on the no-null
constraint).
Here are the migrations:
class CreateNodes < ActiveRecord::Migration
def self.up
2006 Jun 20
1
Preventing Dups in HABTM
I have a habtm that looks like:
report
has_and_belongs_to_many :subscribers
subscriber
has_and_belongs_to_many :reports
When I add a report to a subscriber, I have to run code like:
raise "already there, idiot!" unless
report.subscribers.find_by_id(subscriber_id).nil?
Is there a better way to avoid adding duplicative associations? has_many
:through seems like overkill for this
2006 Apr 04
3
newbie - HABTM problems writing to Join Table in SQL
I am attempting to document a join between two tables. There seems to be
no writing to my database. Please help me out it is driving me absolutly
crazy.
Basically i''ve got a table of directors that is called when the new/edit
controller model for films is activated. It shows the user a selectable
list of directors they can apply to films. The problem is in the
update/create part. I
2006 May 11
1
ActiveRecord collection_select and has_and_belongs_to_many
Hello everyone, first post to the list and a relative newbie to Rails
development. Done quite a bit of JSP, PHP, HTML, XML etc and thought I would
kick the tires on Rails to see if it can speed up development for internal
applications. Anyway, I am running into a problem that is just driving me
crazy and everything I read on the net doesn''t seem to help. I was hoping
someone here might
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 Jun 14
1
HABTM and acts_as_list
I don''t think this needs much explanation. Is what I''m trying to do
even possible?
class CreateLanguagesProducts < ActiveRecord::Migration
create_table languages_products do |t|
t.column :language_id, :integer
t.column :product_id, :integer
t.column :language_position, :integer
end
end
class Language < ActiveRecord::Base
acts_as_list :scope =>