similar to: checking for existence of object in views

Displaying 20 results from an estimated 50000 matches similar to: "checking for existence of object in views"

2006 Mar 07
4
should a AR object be able to see backwards?
I have two models, Stop and Station, they relate one station to many stops. Stop has_one :station Station belongs_to :stop So I can do @station.stops, but I cant do @stop.station, is this right? For example in the view I have: <% for @stop in @stops %> <tr> <td><%= @stop.station.name %></td> <td><%= @stop.time.hour.to_s + '':''
2007 Feb 05
6
Viewing object associated via "has_many :through"?
This is my first question to the Forum. I’ve set up these associations: class Playlist < ActiveRecord::Base … has_many :playlists_tracks, :dependent => :destroy has_many :track_ones, :through => :playlists_tracks, :source => :track has_many :track_twos, :through => :playlists_tracks, :source => :track end class Track < ActiveRecord::Base … has_many
2013 May 13
1
RAILS GET IDS
I don''t know how to solve something about a project I''m doing in Ruby on Rails. I want to save the IDS of my 3 models to my table DETAILS between these, my BD is Mysql. ASIGNATURAS--MALLAS--NIVELS-------->ASIGNATURA_ID--_MALLAS_ID--_NIVELS_ID In the view MALLA, i list my asignaturas, mallas and niveles, and in the controller MALLA i want to save the arrays to my model
2006 Feb 24
4
Problem having two belongs_to of the same class type
I have a Shipment class that is used to ship packages between Branches. However, when I try to have two belongs_to in Shipment called shipped_to and shipped_from I can''t seem to make it work. I can get it to display the form properly but when I select the branches and click save I get the following error... "Branch expected, got String" Any ideas? I have added some code
2007 Jun 19
3
Nil object for nested resource
Hi all, I have 2 models with a standard 1 to many relationship. I''m also using REST on the two models and have added the appropriate code to the routes.rb file. scorecard.rb: class Scorecard < ActiveRecord::Base has_many :attributes end attribute.rb: class Attribute < ActiveRecord::Base belongs_to :scorecard end routes.rb: map.resources :scorecards do |scorecard|
2011 Mar 10
4
Multi-model forms
Hi guys, I''m new to ruby and rails and I''m working on multi model forms, specifically 3. I''m using this http://guides.rubyonrails.org/getting_started.html as a start, and its got a 2 Model example but I cant seem to get the last one working. These are my models: Country name:string code:string (has_one :address) Address address_line1:string
2009 Oct 23
4
error: nested-routes with nested-model having foreign keys
Hi, I have this Test, User and Project models where every test belongs_to a project and project has_many tests. Test also belongs_to User as ''owner''. Then i followed railcast#139 to create nested route as - map.resources :projects, :has_many => :tests But somehow i get this error when url is ''http://127.0.0.1:3000/ projects/1/tests'' in
2010 Jan 08
1
problem using build with has_many :through relationship
Hello all, I''m having problems creating a new record with has_many :through My application is quite complicated so I''ll try to explain it as easy as I can. I have a many to many relationship with Projects, IRBs and Reviews. Where reviews is the joined model. In the new project view, I have a link (add IRB). This will add an a list of IRBs to the new project form. I have visited
2006 Jul 27
0
CRUD, REST and associations
Let''s say I have the model class Reader and Magazine, connected by join model Subscription. It looks something like this class Reader < ActiveRecord::Base has_many :subscriptions, :dependent => :delete_all has_many :magazines, :through => :subscriptions validates_presence_of :name end class Magazine < ActiveRecord::Base has_many :subscriptions, :dependent =>
2006 Apr 24
0
Updating a form containing array of text fields with has_many/belongs_to relation?
I''ve got a User class and an Employer class set up as follows: User.rb: has_many :employers Employer.rb belongs_to :user My tables are as follows: mysql> select id,first_name,last_name from users limit 5; +-----+------------+-----------+ | id | first_name | last_name | +-----+------------+-----------+ | 711 | Patrick | Stewart | | 714 | Larry | Davis | mysql>
2007 Jan 20
1
Not appear error message
I have a partial form "empresa". In new.rhtml of "empresa", I call the partial form of "usuario". Well, it is happening the following: When save empresa, and stop in validates, as much in "empresa" how much "usuario", appear only error message of "empresa", and not of "usuario". Because this happening? ps1.: I use flash_message
2006 Jan 05
1
recipes/categories to books/authors but listing doesn''t work
People, I have gone through the cookbook example: http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=1 and everything worked fine an a FC4/Postgres setup. I then tried to reproduce this success with something that would be useful to me - a library db using books & authors tables. The author list works but NOT the book list (unless I take line #17 out). I get this message:
2006 Apr 14
3
Updateform with a has_many relationship ?
Hello all, I would like to be able to update the "amount" of a certain item in me order list. The problem I run into is how to define the text_field element. @order is the current order, which has_many :order_item which in turn belongs_to :order. order_item has a field "amount" which should be modified... What I tried is this below, but I get a undefined method
2006 Feb 02
4
Doubts on validation
Hi All, View ******** <tr> <td><b>Student: </b></td> <td><%= text_field "student", "fname", "size" => 40, "maxlength" => 40 %></td> </tr> <tr> <td><b>Program: </b></td> <td><select id="student_program_id"
2006 Jun 22
11
Help please
Getting this error: SyntaxError in CompanyController#positionslist (eval):1:in `compute_type'': compile error (eval):1: parse error, unexpected tINTEGER Object::2 I could not find anything out about it (googling) and it''s not the clearest error message. Not sure if it''s related to an expected data type but that wouldn''t make sense. The only other thing I can
2006 Jul 21
1
Passing a variable between methods
Hi, I am trying to add search functionality to may application. I am struggeling to pass my query to the controller and then show all my search results in another view. How would I do this? Model: class Advert < ActiveRecord::Base belongs_to :user def self.search(query) if !query.to_s.strip.empty? tokens = query.split.collect {|c| "%#{c.downcase}%"}
2006 Aug 17
0
super-newb needs help with has_many and other things...
I am brand new to oop and am having a difficult time getting my head around some ruby stuff. In specific, I am trying to create a library style app that lists topics, articles and comments. I have a table called topics, a table called articles and a table called comments. My models, controller and view are all listed below. What I want to happen is to have the list view list each topic along
2006 Apr 30
1
has_many :through, form for join model attributes
I have the following schema: class ClientsProject < ActiveRecord::Base belongs_to :client belongs_to :project end class Client < ActiveRecord::Base has_many :clients_projects has_many :projects, :through => :clients_projects end class Project < ActiveRecord::Base has_many :clients_projects has_many :clients, :through => :clients_projects end I have a form to
2006 Apr 07
1
Formatting form tags for children of parrent data?
This my first Rails project. All my previous work was done it Perl, so I may be missing the Ruby/Rails obvious here. The site I''m working on needs to display archived programs. Some of the programs have multiple versions, all belonging to the same listing. As such, I''ve set-up an extra_files table related to the archive list. Displaying the extra files was trivial. However,
2006 Jun 10
6
table associations
First, thanks to everyone who replied to my pluralization question from before! Today I was trying to do what I think is called a "chained accessor". I have an "events" table and each event has one user. Instead of seeing the id number for each event''s user, I''d rather display the names of users instead. I tried to do this: class Event <