form-for

Rails ActiveRecord Update question

I have a user model which has multiple addresses. Now for my application in rails, address is not mandatory. So, if someone wants to create a user and enter the address after the user has been created, my application should allow that. My problem is, for Address model I have validations for Address Line 1, City and Postal Code. These fie...

RESTful way to use form_for?

I am attempting to use form_for to implement a search form that works with a table-less Search model I created. The search form keeps triggering the 'index' action. I assume I should use 'new' to create the form and 'create' the process the search query. Looking at the log, my POST is getting changed into a GET. Here's my code: /searche...

Attaching onClick event to Rails's link_to_function

How do I attach an onclick event to a link_to_function such that clicking on the event refreshes an element on the page (using partials)? When the user clicks the generated link, I'd like to refresh the partial containing the code so that i gets updated. def add_step_link(form_builder) logger.info 'ADD_STEP_LINK' link_to_func...

Rails, One Model, Many Screens

I have a model with many fields (nearly 40). The client wants the fields divided among multiple screens. The model also has a few has_manys that should look like they are part of the same model. How can one divide the model, and what are the tradeoffs among the ways to do it? I see a couple of possibilities: 1) Use JavaScript to show ...

form_remote_for in rails

HI I tried using a javascript function call in the submit tag of a form_remote_for but it is not able to find the function im calling. if i call the same function from form_remote_for then ajax stops working. can ny one help me how can i call an javascript function when im using form_remote_for NOT FORM_REMOTE_TAG....???? ...

Ruby on rails model and controllers inside of different namespaces

OK. This is insane. I'm new to RoR and I really want to get into it as everything about it that I have seen so far makes it more appealing to the type of work that I do. However, I can't seem to accomplish a very simple thing with RoR. I want these controlers: /admin/blog/entries (index/show/edit/delete) /admin/blog/categories (index...

Rails form_tag form writing - with non-active record model

Hey Rails People, I'm somewhat of a Rails newbie. I'm writing a couchrest-rails app, so am not using activerecord for this model. I just figured out that that means that form_for(@model) won't work. I'm trying to work out how to use form_tag -- but most of the examples don't involve new & create actions. This is wrong: <h1>New ...

ruby on rails / routing-filter / form_for changes html

Hi, this question is related to routing-filter. I have this in my view: <% form_for :post, :url => {:action => "show"} do |f| %> which translates in the browser to this: <form action="/en/posts/show" method="post"> after changing the I18n.locale e.g. I18n.locale = :en the html becomes: <form action="/en/posts/72" method="post"...

form_for tag for a resource with two different controllers and RESTful routing

I have a Rails app with a "Route" resource, and a "Route" controller (not to be confused w/ Rails routes). I've set it up so that the site admins (and only the admins) can manage the "Route" resource through the "Route" controller, while regular users manage their routes with a "Myroute" controller. I want both controllers to utilize R...

STI and form_for problem

I am using Single Table Inheritance for managing different types of projects. Models: class Project < ActiveRecord::Base end class SiteDesign < Project end class TechDesign < Project end Edit action from projects_controller: def edit @project = Project.find(params[:id]) end View edit.html.erb: <% form_for(@project, :url => {...

Helper method that encapsulates two form_for blocks

How do you build a helper method that looks like -confirmation_for [@post, @comment] do |f| = f.confirm "Post" %p html here... = f.edit "Edit" and encapsulates two forms like -form_for [@post, @commment] do |f| = f.hidden_field :submission_state, :value => "confirmed" = f.submit "Post" %p html here... -form_for [@post, @...

RoR: Check boxes in form_for for has_many, :through with a Join model

Once again, I have my form_for for my Order model, which has_many :services, :through => :requests. Here's the layout of how I have my relationships mapped: __________ _________ | Customer | | Utility | ---------- --------- || ^ ...

jrails loading remote_form_tag rails

I recently switched to jQuery using jRails for an app. 99% of all my previous RJS seems to work perfectly, the only except is the :loading => callback when using the remote_form_tag. <% form_remote_tag :url => '/hostels/update_currency', :loading => visual_effect(:appear, :load_currency), :html => { :id => 'currency' } do %> I have ...

Ruby on Rails : symbol as argument in form_for

I understand what is passed to the form_for method when doing something like : <% form_for(@user) do |f| %> ... <% end %> if @user is set in the controller. This is pretty obvious. But what happens when we pass :user, as I have seen in many examples ? <% form_for(:user) do |f| %> ... <% end %> When should I use the symbol version ...

form_for with nested resources

I have a two-part somewhat noob question about form_for and nested resources. Let's say I'm writing a blog engine and I want to relate a comment to an article. I've defined a nested resource as follows: map.resources :articles do |articles| articles.resources :comments end The comment form is in the show.html.erb view for articles...

Parsing blog post tags from a text_field

Ok, so you know how you ask a question here, and in the "Tags" field you can enter several space-separated tags into a single text field? I'm trying to replicate similar behavior in my Rails app. Except instead of questions, I'm doing a blog app (which has "posts"), and tagging those. I'm using "form_for" to build the quick form. Insid...

Trouble getting basic searchlogic plugin code to work in Rails App

To preface this I am a complete Rails newcomer so don't judge my lack of skills too harshly. Anyway, my rails app is throwing this error: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id I am trying to make a basic form that will allow a user to search for a "match" by "country". It ...

how to use an array in form_for?

I've got a user model which contains a field called, lets say, text1. In the users/new form I want to have 4 individual text boxes for this text1. In my model I will take values from these boxes and concatenate them together as comma separated values and store them in the DB. To give you an understanding, this is what I want. <input typ...

Rails form_for is placing object reference/address into URL instead of id

I'm going to head off and look at the source to see if I can find what's causing this, but someone here's probably run into this before so... I'm doing a normal form_for: <% form_for(@myobj) do |f| %> But the URL it's generating is: form action="/myobjs/%23%3CMyobj:0x105f03ec0%3E" class="edit_myobj" id="edit_myobj_13" method="post"> ...

Rails + Haml: Returning from a partial will somehow remove the form tag

This is lengthy, yes, I apologize. But I want to be clear because this issue is so odd. I have a terms of service modal that comes up whenever a user has not accepted our terms of service (TOS). For the purposes here, javascript is turned off and what is rendered is strictly html/css. So the page, if thought of in 3 layers, is: bottom l...