similar to: new objects and new associations in same view

Displaying 20 results from an estimated 5000 matches similar to: "new objects and new associations in same view"

2006 Jan 25
2
select list generated from table
Have 2 tables - clients & case_managers class Client < ActiveRecord::Base has_one :case_manager end app/views/clients/_form.html contains line... <p><% collection_select("client", "case_manager_id", \ case_manager.find_all, "name", "id") %></p> and this line generates error... undefined local variable or method
2006 Apr 24
4
creating a select box
Hi trying to create a select box in _form.rhtml. I have a table called organisations that contains fileds, 2 being ''id'' and ''name'' these are the fields I need to bring over to the clients _form.rhtml. whats the best way of going about that?? 2 ways i have seen suggested that I cant get to work -@organisations = Organisation.find_all placed this in def new
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 Apr 25
1
simple collection_select problem.
Hi, I can do this : collection_select "state", :id, TrainingState.find_all,:id,:name but not this : collection_select "state[]", :id, TrainingState.find_all,:id,:name Anyone any idea why? Is there something about collection_select that does not allow collections? Thanks Chris -- Posted via http://www.ruby-forum.com/.
2009 Jun 14
5
Partials views and instance variables go nil
Hi everyone! Model: http://pastie.org/511290 Controller: http://pastie.org/511285 View new: http://pastie.org/511286 View _form: http://pastie.org/511284 When I hit submit button there''s an error for usuarios(users in portuguese) instance. It does not seems to save usuarios even though it seems to be posted by the form. Error: http://pastie.org/511292 Need some help here guys plz --
2006 Mar 29
11
why belongs_to does not like validation?
This works : class Recipe < ActiveRecord::Base belongs_to :category end But (when I add validation) this does not work : class Recipe < ActiveRecord::Base belongs_to :category validates_length_of :category, :within => 6..20 validates_uniqueness_of :category, :message => "already exists" end thank you -- View this message in context:
2006 May 18
6
Newbie:problem when using validates*
Hi, I have performed the cookbook tutorial. Before tailoring the views and controllers, when I put in the model recipe.rb: validates_uniqueness_of :title validates_length_of :title, :within => 1...20 And I tried to introduce some new recipe without the above conditions I got the message: --------------------------------------------------- New recipe 1 error prohibited this category from
2006 Nov 09
2
help with join tables and has_and_belongs_to_many
Hi, I have a user model and a privilege model. They have the has_and_belongs_to_many relationship. Here are the model defs: class User < ActiveRecord::Base belongs_to :status has_and_belongs_to_many :privileges end class Privilege < ActiveRecord::Base has_and_belongs_to_many :users end Now I have a migration script to create the join table and populate a few users with some
2006 Feb 28
2
Need help with a Power Find()
I was hoping someone would be able to help me with creating a method. I have two tables. What I am trying to do is create a list of all the id''s from table2 that aren''t currently referenced by Table1''s address_id column. That way, when I create a new customer I can have a drop down list in the view of all the addresses that are not currently being used. ##### Database
2006 Apr 26
2
Multiple Select example?
I''ve been trying to sort out a multiple select dropdown but haven''t found any good examples - anyone know of any or perhaps could make a suggestion [see below] Model: 1. Task AR has_many users 2. User AR belongs_to task login/password attributes Controller: View: <%= collection_select("task", "users" , @users, "id", "login", {},
2006 Apr 06
6
select method
The documentation states as an example: select("post", "person_id", Person.find_all.collect {|p| [ p.name, p.id ] }, { :include_blank => true }) could become: <select name="post[person_id]"> <option></option> <option value="1" selected="selected">David</option> <option
2006 Nov 29
5
Collection_select with two columns and a prompt
Hello, I am quite a newbie to RoR, I hope you maybe able to help. I have a collection_select in a _form.rhtml: "collection_select(:assets, :model_id, @models, :id, :model_ref,options={:prompt => ''- Select a model -''})" As you see my drop down menu will show the model_ref column. 1) Is it possible to have more than one column. For example I would like to
2005 Jun 13
3
validations not working with collection population droplists
I have an ADD form with foreign key field values selectable via select list ( collection_select (...)). When I add validates_presence_of :someotherfield to my model for error trapping, I get the following error for each droplist: NoMethodError in Reviews#create_curriculum Showing /reviews/_form.rhtml where line #16 raised: undefined method `inject'' for nil:NilClass Extracted source
2006 Jan 08
2
RoR AJAX select box update?
Hi, I want to update a select box depending on another selected option thru ajax. Heres how I do it # _form.rhtml <select id="budget_coordinator_id" name="budget[coordinator_id]" onchange="<%= remote_function(:update => "budget_project_number", :url => { :action => :get_projects }) %>"> <%=
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
2006 Jan 10
5
Select Tag and Associations
Hi there, I''ve been working on this for awhile and have finally decided to ask for a little guidance.I have a slight problem trying to save a selection. I have two models: A "Posting" has_many "Categories", and a "Category" belongs_to one "Posting". With that said, in the posting model I have "has_many :categories" and within the
2011 Feb 17
1
(no) new join table entry by collection_select
Hi there ../view/trainings: in my _form.html.erb I use a collection_select to get the id of a worker from Worker-table. <%= collection_select(:worker, :id, @workers, :id, :first_name, options ={:prompt => "Select a worker"}, :class =>"worker") %></div> The collection select shows correct, but there will be no entry in the worker_id field of the new entry.
2006 Apr 05
1
select in *.rhtml
I''m trying to get a select box of categories to appear in my items views after I created everything using generate scaffold, but I can''t get the categories to appear in my forms. class ItemsController < ApplicationController def new @item = Item.new @category = Category.find_all end ... class Item < ActiveRecord::Base belongs_to :category end class
2009 Jul 18
2
Sharing controllers/models within a view
Hello, please forgive me if this answer is obvious! I''m new to Rails this week. I have two database tables, and the associated scaffolding, controllers, models and views. The first is service_provider, which holds a list of service providers. The second is service_provider_countries which is a table of countries (obvious perhaps). In views/service_providers/new.html.erb I have a form,
2006 Jan 03
4
validates_presence_of *_id attributes
Hi all, I am a newbie to Rails. Please enlighten me on how to do this appropriately, the Rails and the Ruby way: Suppose I have a Recipe model. Let''s simplify things and pretend that it has only 2 attributes, a :name and the other is a ''category_id''. In the recipes table, category_id is a foreign key to field id of table categories. We also assume that I have generate