Displaying 20 results from an estimated 20000 matches similar to: "HABTM Reading Rows From Two Tables"
2007 Jan 03
3
Self-referential habtm with condition is broken
Here''s a simplistic model class.
class Person < ActiveRecord::Base
has_and_belongs_to_many :relatives,
:class_name => ''Person'', :join_table => ''relatives'',
:foreign_key => ''from_id'', :association_foreign_key => ''to_id''
has_and_belongs_to_many :brothers,
:class_name =>
2007 Dec 05
5
Active Record, Migration, and Translation
Hi,
I think the columns and table in migration should be able to have an
optional "display_name" set manually. Something like:
create_table :people, {display_name => "Personne"} do |t|
t.column :first_name :string, :display_name => "Prénom".
end
Let me explain my point of view:
Rails is a framework made to write programs in English. You see it when
you
2006 Dec 27
0
HABTM Checkboxes - Adding/Updating Users to a Project
Hello all,
I''m trying to create a HABTM checkbox action that adds/updates ''users''
to a ''project''.
I have the following laid out.
---------------------
TABLES
---------------------
create_table "assignments", :id => false, :force => true do |t|
t.column "project_id", :integer, :default => 0, :null => false
2013 Oct 23
3
Rails 4 and HABTM Checkboxes: Unpermitted parameters error
I have a simple Rails 4 project with two scaffolded models: Practice and Practitioner. I have set these both as habtm and am in the process of adding checkboxes to the Practitioner form so that I can check off the practices that this practitioner belongs to. In the practitioners_controller, I added practice_ids to the practitioner_params permit list, but I am still getting the error:
Started
2007 Sep 06
2
HABTM Loops
So, I have a "schedules" table and a "hours" table, joined by a
"hours_schedules" table. Think of the hours table as a category for
when people will schedule themselves to work, which happens in weekly
increments. At any given hour, there will be X number of people
working. I need to represent each worker with an asterisk symbol in
the weekly view. For example,
2006 Jul 23
8
destroy vs delete
what is the difference between destroy and delete in AR
I am not sure what they mean by
"Destroys the record with the given id by instantiating the object and
calling destroy<http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000866>(all
the callbacks are the triggered). If an array of ids is provided, all
of them are destroyed."
in
2006 Jan 04
5
habtm recusive
I have a people table:
CREATE TABLE people (
id int(10) unsigned NOT NULL auto_increment,
first_name varchar(75) default NULL,
middle_name varchar(75) default NULL,
last_name varchar(75) default NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1272 ;
and a people_people table:
CREATE TABLE people_people (
person_id int(11) unsigned NOT NULL,
2006 Feb 20
0
No Magic for HABTM forms?
Hi,
I posted yesterday asking how to get form tags to reference the
associated objects in a habtm relationship. I was hoping for Rails
Magic, but it looks like Rails doesn''t have habtm magic beyond a
certain point.
Here was my solution for others who might have the problem. Also, I
hope someone shows me that there is a simpler way.
The Database Model:
class Registration <
2010 Jun 05
6
How do you update HABTM relationships or create.
Hi,
I have a User model with a HABTM relation to a Role model and vice
versa. So There''s a roles_users table that references :user and :role.
I''m using formtastic, and in the user.edit.html.erb I have a line that
outputs the roles as a multi-select list box. But the box is not
showing the roles that have been assigned to the users.
Another problem is that if I select a few
2008 Jul 13
2
Problem with ActiveRecord::AssociationTypeMismatch
Hi all !
I''ve written a Character model, each character has many Attributes. My
schema.rb looks like this:
create_table "characters", :force => true do |t|
t.string "first_name"
t.string "last_name"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "attributes",
2007 Jul 17
5
habtm confusion
Hello friends!
I am trying to make a database that will have a group of people set to
committees, and a person can be in multiple committees, and a committee
obviously has multiple people. The people are senators at my
university. These are my current models:
senator.rb:
--
class Senator < ActiveRecord::Base
validates_presence_of :first_name, :last_name, :floor
has_and_belongs_to_many
2006 Dec 14
12
Saving dates
Hi having trouble saving dates in my form i have the following in the
view
<%= date_select("details", "open_date") %>
and i have
@exhibition.open_date = params[:details][:open_date]
and then
@exhibition.save
All the other values form (not seen here) get saved but not the dates.
What am i doing wrong ?
--
Posted via http://www.ruby-forum.com/.
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
2007 Aug 26
2
Multi-word query searching across columns
I''m trying to implement a basic name search on a People table with
separate first_name and last_name columns. I am using the
will_paginate plugin and have the following search method in the
model:
def self.search(search, page)
paginate :page => page,
:conditions => ["lower(last_name) like ? or
lower(first_name) like ?",
2008 Jul 20
10
STI and fixtures
Hi all !
Loading fixtures doens''t seems to associate my 2 objects, do know what''s
wrong ?
In app/
class Manager < Employee
has_many :employees,
:foreign_key => :reports_to
end
class Employee < Person
belongs_to :manager,
:foreign_key => ''reports_to''
end
class Person < ActiveRecord::Base
belongs_to :address
end
fixtures for
2006 Jun 23
3
form_remote_tag is not passing form params
I''ve searched and searched and searched again, and I cannot find any
help with this problem. There''s an identical problem on this forum, but
it was never resolved. I''ll try to re-open the subject with a bit more
information.
Problem: The form_remote_tag() method in my "list" view is not passing
the params[] hash of the values stored within my form.
2006 Feb 03
4
contoller code mysteries
In my controller...this code works
def list2
first_name = params[:client][:first_name]
@myclients = Client.find(:all, :conditions =>
["first_name = :first_name", {:first_name => first_name}])
end
this code doesn''t...
def list2
first_name = params[:client][:first_name]
if first_name
searchstring = ''["first_name =
2010 Oct 05
2
Is it possible to query on virtual attributes?
I have a Person model with attributes first_name and last_name.
I want to implement autocomplete search that looks that the entire
name. Hence I have a method:
def full_name
self.first_name + " " + self.last_name
end
Is it possible for me to query on full_name and have rails match the
first_name and last_name fields?
I currently receive this error when I try, because full_name
2006 Jan 19
0
Help with nested HABTM relationship
Hi,
I am trying to perform a query with ActiveRecord that I want to put into
a Rails application later. For now I just wrote it within a plain old
Ruby script for easier testing.
I am working with an existing database so I had to map some foreign keys
myself. As you can see from the models below, the database has a
structure of
Prospectlists <=habtm=> Contacts <=habtm=> Accounts
2010 Jan 20
0
need help with nested forms and habtm
Hi,
I''m currently stuck with a problem I just can''t find a clever solution
for. I checked every tutorial, issuetracker, API reference I could
find but found nothing to "enlighten" me --> I desperately need your
help :-).
My Question is: is it possible to use nested forms for habtm
associations?
--> Here some more info about what I wanted to do and what failed