similar to: How do you create a controller & view to create a list of objects?

Displaying 20 results from an estimated 5000 matches similar to: "How do you create a controller & view to create a list of objects?"

2006 May 17
10
HABTM << producing incorrect insert sql ?
Greetings railsers - I''m trying to add to a collection through HABTM, but the sql insert is trying to insert a PK rather than letting mysql produce the auto_increment''ed PK. ## @medication_dose holds a validated, saved model @medication_dose.medication_frequencies << MedicationFrequency.find (:all) The above bails with, Mysql::Error: #23000Duplicate
2006 Jan 21
7
n-way joins
Hi, I''m somewhat of a Rails newbie and am trying to understand how to formulate n-way (3 or 4 way) joins in Rails (where the join tables contain extra data as well.) Let me give you my basic entities: foos id - pk name - unique bars id - pk name - unique bazs id - pk name - unique frozs id - pk name - unique then i have two separate join tables: foos_bars_bazs - 3 way join
2006 Jan 08
1
Using many-to-many relations in tests
Hello, I have some many-to-many relations, I would like to use in my tests. But I''m not sure what I should put in the fixtures for it? How do I add those relations in the testing environment? Greetings, Gitte Wange
2006 May 07
2
label tag with errors?
I''d like to create a label tag that has a special css class if has errors. So Ideally, I''d like: <%= label(''object'',''property'',''Property'') %> To generate: <label for="object_property">Property</label> And if there are errors on object.property, generate this: <label
2006 Oct 31
4
Auto-increment lost during migration.
Hi. I get some strange results when using rename_column on a primary key in a migration. It seems like the migration script removes the auto-increment property if you rename a column. This is a minimal example. create_table :foo, :primary_key => :foo_id do |t| t.column "name", :string end # renaming the primary key makes auto-increment disappear. rename_column
2006 Jul 26
15
Rails without a primary key
I''ve been trying to use Rails on a database where the biggest datawarehouse-style table doesn''t have a primary key. It really doesn''t make sense and just adds extra unnecessary space. I do have, however, a column that I normally use to search on (IP) that returns many rows. The table also references several other tables through rails-friendly foreign keys. Simple AR
2006 Jul 03
6
help!
Hi, i''m fairly new to ruby on rails, and i know the question at hand may seem simple at first, but i''m getting really caught up in trying to understand this and the docs aren''t giving me answer. i actually thought i knew how the sql commands work (like :include, :conditions, :etc) but obviously, i don''t. there are three models M1, M2, M3 joined by a habtam
2006 Jan 03
4
Set the foreign key constraint column name?
I am applying Rails to an existing schema and not sure how much the existing developers will let me go in and rename things. So I need to discover the limits of what I can change with Rails. I''ve found set_table_name and set_primary_key, which have been very useful. If I have a "foo has_one :bar" relationship, but then in the bar table my column is named "fooid"
2006 Jul 06
1
Problem implementing password and password confirmation
Hi, I''m trying to implement password confirmation, based on the Agile example, but just can''t make any progress. User DB has these fields: ========================= t.column :name, :string, :limit => 40 t.column :hashed_password, :string t.column :salt, :string User model has: =============== attr_accessor :password_confirmation
2006 Jun 22
1
acts_as_taggable gem problems
With acts_as_taggable 1.04... 1. how can I get a frequency of tags? i.e. /tags/list I want to list of tags sorted and listed with their frequency tags_controller.rb: def list @tags = Tags.find_by_sql ''select name, count(*) as freq from tags group by name order by freq desc'' End tags/list.rb: <ul> <% @tags.each do |t| %> <li><%= t.freq %>
2006 Jul 16
0
Why does belongs_to handle "conflicts" this way?
When you define belongs_to in a model, you can either access association or association_id. I was wondering how Rails would handle things if you set each one to be different. I made two simple models: class Foo < ActiveRecord::Base; end class Bar < ActiveRecord::Base belongs_to :foo end Now here''s a script/console session. >> f = Foo.create => #<Foo:0x270ec10
2006 Nov 28
2
Twice the same code, but only once it seems to work
Hello, I am confronted with a very strange problem which I can not solve... and God I tried a lot, lost almost a whole day, but couldn''t find an answer: The idea is to have a form both in admin and in dir, in admin there will be some more fields that is why I have twice a form. In admin the form appears, in dir the form does not appear instead "þÿ New company" why is it that the
2006 Mar 01
1
observe_field question
I''m sure this is a simple problem, but I''ve been working on it for a couple days and can''t seem to figure out the correct way to structure my observe_field call. The HTML and Javascript generated all appear correct, but the AJAX call is never made. Below is the code I''m using and any help would be much appreciated. models_controller.rb def
2006 Jan 14
6
Error installing Rails/FastCGI/Apache2
Trying to install rails/fcgi/apache2. Following these instructions: http://xmlareas.com/ruby-rails-howto.html Using Fedora Core 4. I installed ruby and ruby-devel using apt-get. Everything under Adding FastCGI (optional) works fine up to the gem install fcgi part. Here is what happens: [root@paulbarry fcgi-2.4.0]# gem install fcgi -r -- -with-fcgi-lib=/usr/local/fcgi/lib
2006 Jun 07
1
Setter that converts a float attribute to integer
Hi, I have some problems with an application where I''m using custom accessors to do currency conversions. In my model, I have a price attribute in the database that stores the value in cents, to avoid future problems with float arithmetic and round. But at the views, I would like to show the price in euros, with decimal for the cents. So I defined a new attribute called price_in_euros,
2013 Feb 28
2
Create polymorphic resources
Hi I have created a polymorphic association for comments since I need commenting functionality on several models. The issue is that when I create the comment in my Commets#create action, I really don''t know what type the parent is of. So, let''s say I have Foo, Bar and Comment. Comment have this: belongs_to :commentable, polymorphic: true And Foo and Bar both have:
2006 Jan 03
6
Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
Thanks for the input Blair Zajac and Chris (Nolan and Hall), and for others. If all of you have time, please follow this (the question still relates to the previous posts by me): I have provided full steps to reproduce the symptoms. If it matters, I''m running Ruby 1.8.2, Rails 1.0, and MySQL 5.0.15 on Windows XP Professional. 1. First, the setup MySQL ----- create database testdb;
2006 Mar 15
7
Populating text_tag with serialized data
I am using a serialized attribute in one of my models The serialized data is in the form of an array. I want to have a text_tag for each element contained in my serialized attribute. How would I construct the text_tag? My model name is ''questions''. The serialized attribute is "answers" So I might have: <% form tag %> <% text_tag ''question'',
2006 Jun 07
2
Problem with a setter that converts euros to cents
Hi, I have some problems with an application where I''m using custom accessors to do currency conversions. In my model, I have a price attribute in the database that stores the value in cents, to avoid future problems with float arithmetic and round. But at the views, I would like to show the price in euros, with decimal for the cents. So I defined a new attribute called price_in_euros,
2005 Dec 16
12
validates_presence_of not working
Hi, I''m new to ruby and rails. I just created a simple update page and the update works fine if all form fields are filled in. However there is one field that should never be allowed to be blank. So I put this in my model: class Topic < ActiveRecord::Base validates_presence_of :dr_title validates_length_of :dr_title, :minimum => 1 So, when I submit the form with a blank