similar to: Using Field Helpers to Edit a Related Model Object

Displaying 20 results from an estimated 20000 matches similar to: "Using Field Helpers to Edit a Related Model Object"

2006 May 19
2
1 Form for Model containing another Model??
Hi, I can have a Person model with a "has_one :address_email" association, then do the following in my controller: @person = Person.new @person.address_email = AddressEmail.new But, when I have 1 form for "Person" in my view I can''t bind fields in the @person.address_email object with text_field or text_field_tag helpers without getting a "undefined local
2006 Mar 10
2
adding to has_many on create and edit
Hello, I am fairly new to RoR and I have a question I hope can be solved elegantly (so many things are, so why not this one too?). I have a working solution, but I want to be sure I am doing things the "rails way" (having come from PHP). You could say I am looking for a little validation (no flames please). I have a table of units like so: CREATE TABLE `units` ( `id`
2006 Jan 05
2
help - edit without using scaffold
Hello, What am I doing wrong? The code below does not show the current record for editing. def edit @user = User.find(params[:id]) end def update @user = User.find(params[:id]) if @user.update_attributes(params[:user]) flash[:notice] = ''User was successfully updated.'' redirect_to :action => ''show'', :id => @user else render :action
2006 Jul 02
5
Question about setting field values for a belongs_to model
I have two tables, applicants, and skills where each applicant "has_many" skills, and each skill "belongs_to" an applicant. When I have a reference to an applicant and a (skill) id for one of their skills, I thought to update their skills by using @applicant.skills.find(id_of_skill).description = ''new description'' # even adding
2007 Jul 31
0
Edit not working with named routes
HELP! I''m a relatively new rails user and I''m stuck. I''m trying to build a relatively simple blog and I decided that I liked the way named routes look in the code. So I added map.resources :posts to my routes.db file. I then went through and updated my controller to take advantage of the named routes that were generated. I also updated all of my views and everything
2006 Apr 08
2
ActionView::Helpers::FormHelper instance methods should take an object reference rather than an object_name.
Hi ActionView::Helpers::FormHelper methods (e.g. #text_field, #check_box...) take object_name as an argument. From this argument they infer a name that is supposed to contains the reference to the relevant object. I can''t see why the FormHelper methods were designed that way. Compared to simply passing them a reference, the current way seems too complicated and an invitation to problems
2009 Nov 06
0
Nested objects not propagating from view
I thought I had this fixed, but apparently not. It works okay from the console, but not from the view. I have the following: # partial schema create_table "users", :force => true do |t| t.string "login", :null => false t.string "first_name" t.string "last_name" t.string "email", :null => false
2006 May 04
1
Instance or local vars for field helpers in partial template
I''m getting confused. If I have a view (.rhtml), I can use a field helper like: <%= text_field :mymodel, :attribute %> This uses the value from @mymodel.attribute Now, if I am rendering a template normally (i.e. not partial), I would expect @mymodel to be a model object defined as an instance variable in the controller. However, if I am rendering a partial template, I
2006 May 11
1
RoR completely ignoring a column when saving changes
I have an action that needs to update two models/two tables in one shot, and it works great, but ignores one column. Here is the action code: (verify_id is irrelevant in this case) [CODE] def edit @page_title = "Edit User" @page_active_3 = "active" if request.post? @user = User.find(params[:id]) @profile = @user.profile verify_id(@user.id,
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
2006 Jul 27
1
Weird issue with editing data.
Hi all. Ive got a small CRUD app that is giving me some weird isuses. If I add/create an entry that works fine, the data goes into the db. I can later show the data, but when I edit it, no data is displayed in the form for me to edit. Here is the bits from the controller. def new @kb=Knowledgebase.new end def create @kb= Knowledgebase.new(params[:kb]) if @kb.save
2006 Jul 08
2
Creating/Saving dependent objects
Folks, Am new to RoR and am building an example to get myself familiar. I am running into a simple issue while creating a user registration page. I have a User and Address models defined as below (partial/relevant code included below). User has_one address and Address belongs_to user. I have a foreign key defined in address table that refers to user(id) In a form I take in username, password,
2006 Apr 01
0
select_tag problem
Hi I have a feeds db described like this: | id | int(11) | NO | PRI | | auto_increment | | url | varchar(255) | YES | | | | | name | varchar(255) | YES | | | | | type | varchar(255) | YES | | | | | valid | int(11) | YES | | | | In my feeds view i have :
2008 Mar 03
15
update_attributes not updating
For some strange reason I can''t get update_attributes to work. Any reason why that might be? here is my code: controller: def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = ''Your Information was successfully updated.'' format.html { redirect_to(user_url(@user))
2010 Apr 06
1
captcha in a belongs_to
Hi I am using simple_captcha. I have two models User and Staff. Relation ship are User has_one staff staff belongs_to user Now in the staff edit I have to include a captcha. I did like <% form_for @user, :url => staff_url(@staff), :html => {:method => :put } do |f|%> <p> <%= f.text_field :first_name,:maxlength => 50 %> </p>
2007 Jul 25
5
editing multiple models in one form
Very new to this but would appreciate a hand as this is driving me mad, I''m trying to update both degree and assigned from a single form, the degree section updates fine but assigned just retains the same values, any help much appreciated! my edit.rhtml file looks like: <h1>Editing degree</h1> <%= error_messages_for :degree %> <%= start_form_tag :action =>
2007 Sep 20
2
Rendering a partial from within that partial
I am having trouble rendering a partial called ''names'' through a submit tag located within that partial. The form data is saving with my current code. However, the existing data is not loading into the form and the partial is not being re-rendered upon submission to reveal the changes to this data.What might I do to fix this? show.rhtml <%= javascript_include_tag :defaults
2006 Jun 20
0
No opening form tag in rendered HTML
I cannot get my form to submit for my simple blog site (based on the "How to Build a Blog Engine in 15 Minutes" presentation) Any ideas? Thanks, Tom ---------------------------------------------------------------------------- Here is my code: #Post controller class PostsController < ApplicationController def index list render :action => ''list'' end
2006 Feb 20
0
How to reference a field of an associated object in a text_field
Hi, I hope someone can help, I am stumped. I have a Registration ActiveRecord object. It records registrations for people for classes. class Registration has_and_belongs_to_many :people has_and_belongs_to_many :scheduled_courses end I have a form that allows someone to register. A registration form will register two people. They fill in their names, addresses, and the classes they
2005 Nov 30
8
nested attributes with update_attributes()
Hi, I am trying to use the update_attributes on object with nested attributes and I am getting the following error: ProductPrice expected, got HashWithIndifferentAccess Here''s the situation (simplified): class Product < ActiveRecord::Base belongs_to :productPrice end class ProductPrice < ActiveRecord::Base has_one :product, :dependent => true