form-for

A field in a rails form to select a 'belongs_to' object

Oh so please bear with me... I have a model for bookings and a model for drivers. A driver has many bookings and a booking belongs to a driver. When adding or editing a booking, I want the user to be able to type the username of the driver. Usernames are unique and easier for the end user than giving each driver a number. Now this is h...

Ruby on Rails testing: How can I test or at the very least see a form_for's error_messages_for?

I'm working on creating a tests, and I can't figure out why the creation of a model from a form_for is failing in the test but works in real browsers. Is there a straightforward way for me to see what the problems are in the model creation? Even better would be, is there a straightforward way for me to test the error outputs that I acc...

Rails form.text_field getting undefined method while rendering view

Hi there I'm trying to run the following code: <% form_for :user, :url => {:action => :welcome} do |f| %> <table> <tr> <td align="right"><%= f.label :name %></td> <td><%= f.text_field :name %></td> But I'm getting "undefined method" when I try to run it using cucumber/webrat, while rendering the page. Running on the web brow...

Routing problem with calling a new method without an ID

I'm trying to put together a form_tag that edits several Shift objects. I have the form built properly, and it's passing on the correct parameters. I have verified that the parameters work with updating the objects correctly in the console. However, when I click the submit button, I get the error: ActiveRecord::RecordNotFound in Shif...

Nested resources in namespace form_for

Problem The form_for helper incorrectly determines the path to my nested resource inside of a namespace. The models in question are: Forum::Thread and Forum::Reply respectively, located in a subfolder called "forum" under my models directory. This is in Rails 3 BETA 3. routes.rb namespace :forum do root :to => 'threads#index' ...

form_for with json return

I currently have a form like this: <% form_for @stem, :html => {:multipart => true} do |f| %> <%= f.file_field :sound %> <% end %> This outputs (essentially): <form method="post" id="new_stem" class="new_stem" action="/stems"> <input type="file" size="30" name="stem[sound]" id="stem_sound"> </form> However I'm planning to use jQuer...

form_form and custom parameter in path_prefix

Hi people, I have this route: # config/routes.rb map.namespace :backshop, :path_prefix => '/:shop_id/admin' do |backshop| backshop.resources :items end And I want to use the form_for magic to reuse the same form on both: new and edit views: <% form_for [:backshop, @item] do |f| %> This used to works, and used to build a create ...

Nested form problem in Rails : NoMethodError in Show

I'm trying to build a simple product backlog application to teach myself Rails. For each product, there can be multiple product backlog entries, so I want to create a product view that shows the product information, all the backlog entries for the product, and includes a nested form for adding more backlog entries. Everything works unti...

rails 2.3.8 - form_for with namespaced nested model

Hello there, I'm struggling to get this working. I have the following routes: map.namespace :admin do |admin| admin.resources :languages do |language| language.resources :courses end end So, basically an admin namespace and the languages models which has_many courses and obviously a course belongs_to language...

RoR form_for: Hidden field isn't being included within the object paramater and therefore doesn't work.

I'm using a form to add an entry, and I need to send the id of the current user along with the entry parameters. Here is my form code: <% form_for(@entry) do |f| %> <%= f.error_messages %> <%= hidden_field_tag 'user_id', current_user.id %> <p> <%= f.label :date %><br /> <%= f.date_select :date %> </p> <p> <%= f.labe...

rails' form_for, form_tag no longer working

I have multiple forms in my rails app that were working perfectly up until last night. With no actual modification of anything to do with forms, none of my form tags are even showing up in the HTML anymore. Is there any quick fix for this, or any known reason this would occur? Thanks! ...

routing scope problem with form_for (partial)

Trying to route: scope :shortcut do resources :text_elems end Using basic scaffold with form partial *_form.html.erb* <%= form_for(@text_elem, :shortcut => @shortcut) do |f| %> ... Problem is: When I call the edit action, the form html shows as: <form ... action="/25/text_elems/25"> Note: The new action renders the form acti...

Access Rails Method Defined In Model Through View In Rails 3

I have a method defined in my controller that I am trying to create a button or form to access. Model class DoThis < ActiveRecord::Base def take_action(a, b) end end View <%= @do_this.take_action(@a, @b) %> I would like to convert the above code in the View to a button_to or form_for but cannot figure out how. Thanks ...

rials form_for creates a new database entry on refresh, without form submit

I'm new to rails and mongodb, and have a simple form attempting to create a category tree. Whenever I refresh the page, a new entry is put into the database. I'm not clicking the 'submit' button, just page refresh. The form looks like this <%= form_for Activity.create do |f| -%> <%= f.text_field :activity_name % > <%= f.submt "a...

Ruby on Rails: Use form_for on a model, and flip the form value

I've got a form_for form, and within it, I'm using a form helper check box. The model has a field that's a boolean value, but I'd like to be able to display it on my form in terms of its converse since I think that's easier for users to understand. Is there any way for me to have a Rails form helper act as if the model's boolean field i...

rails ajax requested form has wrong method

Hello, I have a _form.html.erb partial that comes from the standard rails 3 template for the model project. #view: <div id="content"> <%= link_to 'Edit', edit_project_path(@project), :remote => :true %> </div> #projects controllers def edit @project = Project.find(params[:id]) respond_to do |f...

How do I use multiple "one-to-many" nested attributes in form_for

given the fact that a user has many credit cards and a credit card has many addresses, I am trying to create a form that creates a user and credit card with address all at once relavent model code: class User < ActiveRecord::Base has_many :credit_cards accepts_nested_attributes_for :credit_cards end class CreditCard < ActiveRecord...

Ruby on rails: singular resource and form_for

I want user to work with only one order connected to user's session. So I set singular resource for order routes.rb: resource :order views/orders/new.html.erb: <%= form_for @order do |f| %> ... <% end %> But when I open the new order page I get an error: undefined method `orders_path` I know, that I can set :url => order_pat...

form_for and scopes, rails 3

Hi I have a problem due to scopes and the form_for helper in rails 3. The routes - file looks like this: scope "(/:tab)" do resources :article end The form looks something like this: <%= form_for(@article) %> <%= f.label :title %> <%= f.text_field :title %> etc. <%end%> The tab - attribute is stored in params[:tab], as ...

Upgrade to Rails3 from Rails3.rc2, and forms are blank

Why does the following code work in Rails 3 rc2 but not in Rails 3? <%= form_for :product, Product.new, :url => products_path() do |f| %> <%= f.text_field :name %> <% end %> I have formtastic installed but when I took it out I get the same result. I started this project before Rails3beta 1. Should I have...