formtastic

Rails: ValidationReflection and Formtastic not working together

I installed validation_reflection as a gem and out of the box it picked up on my validates_presence_of validations. But it is not picking up on any of the other default rails validations such as validates_format_of. I know from the documentation that i am supposed to add something like: config.reflected_validations << :validates_for...

Formtastic + nested categories

I have an article model and an category model. Category act as tree. What is the best approch to build a select list to allow the administrator to select an category from a select list to associate it later with an article ? semantic_form_for(@article) do |f| f.input :title, :as => :string f.input :content, :as => :text f.input :...

Formtastic nested model form fields (Rails 3)

So here's the scenario: User: has_one :company accepts_nested_attributes_for :company Controller: @user = User.new @user.build_company View: <% semantic_form_for @user, :url => register_path do |form| %> <h2>User Information</h2> <%= form.inputs %> <h2>Company Information</h2> <% form.semantic_fields_for :company do ...

Custom Formtastic Control with Multiple Parameters

I'm attempting to build a custom control for Formtastic that takes a latitude and a longitude, however, I'm not sure how to go about passing the method names through. Ideally I'd have the following in the semantic_form_for block: f.input :latitude, :longitude, :as => :location I've also tried passing with an array: f.input [:latitude...

Why won't formtastic reflect attr_accessible in the model (Ruby on Rails)

Why won't rails reflect attr_accessible in my model? class User < ActiveRecord::Base acts_as_authentic attr_accessible :name, :email, :phone, :password, :password_confirmation ... When I use formtastic or outprints the model xml, both reveals all the model fields like admin:boolean, password-encrypted:string and so on. Rails 2...

HABTM Formtastic as check_boxes defaults all check_box options to selected on new action

I have a HABTM relationship on one of my models. I'm using formtastic for my forms. On a new action when choosing to output my column (HABTM) as check_boxes I see all my options appear, however they are all checked on by default. Ideally I want them to not be selected on a new action. When I uncheck a few options and save them, I will se...

Using Formtastic to select from a radio set and optionally create a new record

I've begun using Formtastic in the last couple days and have come to my first head-scratcher. I'm working with items that each have a few associated accounts. On the page in question you need to select a payee account. It can either be an account we already know about (the "Main Contact") or a new account that you can create by fillin...

rails formtastic habtm in and out

EDIT: looking for this: http://diminishing.org/extending-formtastic-with-a-sprinkle-of-jquery (If this works I'll answer my own question) I've started to create an in and out type habtm (has many and belongs to many) form through formtastic. However I would like it to be more flexible to the user, meaning if you select a name on one si...

Nested form errors

Hey, I'm putting together a form to create an order, where one order has many order items. I have it working so it lists all the available products with blank quantity fields, and the user can update those fields to order large amounts of each product. I validate the numericality of the quantities in the order item model. The only is...

Rails: How to use select in formtastic with activeRecord

I'm new to rails and I guess you can answer this question easily. What I got so far is = f.input :task, :as => :select, :collection => @tasks, :include_blank => true where the tasks collection is defined by Task.find(:all) within in the controller. This does in fact work, shows me a dropdown-list of all Tasks to select from and c...

fields_for, formtastic, ActiveMerchant, and validation errors

I'm trying to use Formtastic to create a payment form, since I'd like to use the inline errors. I'm using ActiveMerchant to handle the billing. I have the following form: <%= semantic_form_for @payment do %> <%= form.inputs do %> <%= form.input :email, :label => "Email Address" %> <%= form.semantic_fields_for :credit_card_at...

formtastic radio buttons and textfields

I have model Stub in y project, and in a formtastic form I would like to make such behaviour. Given I have two radio buttons First radio means I send some default data in 'my_field' in Stub model Second radio is to enable user a text field that he will use to send his own data to 'my_field' in Stub model Any ideas that will not mess to...

Cutsom Input for formtastic, what am i doing wrong?

Hi I have made a custom input method for formtastic, it is designed to work with carrierwave and it works great but with one exception, the preview image and other html will not render, as it is being sanitized (i think). Am i going about this completely the wrong way? Here is the code: def carrierwave_input(method, options) c = b...

How to properly pass collection for input in Formtastic

I need to pass a collection to the standard select input in Formtastic: f.input :apple, :as => :select, :collection => Apple.all The problem is, though that I need Formtastic to access a different method than name. Now this is really a problem. I can always pass the Array f.input :apple, :as => :select, :collection => Apple.map { |a|...

Formtastic internationalization of select-tags

Could you tell me how to add internationalization for select tags in formtastic? # view .... f.input :hair_colour, :as => :select, :collection => HAIR_COLOURS .... # user.rb class User << AR validates_inclusion_of :hair_colour, :in => [0..8] end # de.yml de: profile: hair_colour: 0: "Blond" 1: "Dunkelblond" ...

Using Formtastic's semantic_fields_for with a has_many association

I am trying to create a nested form using formtastic. I've included my code below but am running into some problems that I've also listed below. Any suggestions? Thanks. # Home model class Home < ActiveRecord::Base has_many :home_members accepts_nested_attributes_for :home_members, :reject_if => :all_blank, :update_only => true, ...

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

Using ruby 1.9.2 if I change gem 'rails', '3.0.0.rc2' to gem 'rails', '3.0.0' None of my forms render. My forms all use <%= %> and everything works great in rc2. I don't even get any errors. <%= form_for(@user) do |f| %> Not even this text would render.... Its not even hidden on the page. <% end %> This is my GEMFILE: ...

Why is accepts_nested_attributes_for not working for me? (rails 3)

I'm using formtastic and haml on a Rails 3 application. I'm trying to make a nested form for surveys and questions, but it's just not working for me. I've watched the railscast and on it and everything, but I can't seem to make it work for my application. So right now, I have the following: models class Survey < ActiveRecord::Base at...

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...

Accessing object of form in formtastic

So I'm making a survey app. The users choose a type of form on the backend, and it displays as a certain type on the front end. That's only ideally, of course. What happens now is I can't access the object formtastic is building the form for. How can I say something like "question.kind"? It just makes an error that way. Here's what I hav...