Search Results

Search found 41 results on 2 pages for 'formtastic'.

Page 1/2 | 1 2  | Next Page >

  • How do I load Formtastic to test it?

    - by Alan
    I am using Rails 2.0.2 and following Github installation instructions: 1. add as gem source ie "gem sources -a http://gemcutter.org/".....ok 2. install gem ie "gem install formtastic"....gives error, could not find formtastic locally or in a repository I am learning Ruby on Rails and have no knowledge of gems

    Read the article

  • No-Model Formtastic Form

    - by Kevin Sylvestre
    I am looking to reproduce the following with Formtastic: <% form_tag '/search', :method => 'get' do %> <%= text_field_tag :q, params[:q] %> <% end %> So far I have: <% semantic_form_for :search, :html => { :method => :get } do |form| %> <% form.inputs do %> <%= form.input :q %> <% end %> <% end %> However, this requires access to the parameter hash using: params[:search][:q] Instead of my required: params[:q] I'd like to use Formtastic for all forms in the application I am working on, and so far I have only had problems with this one. Any ideas?

    Read the article

  • How to add and remove nested model fields dynamically using Haml and Formtastic

    - by Brightbyte8
    We've all seen the brilliant complex forms railscast where Ryan Bates explains how to dynamically add or remove nested objects within the parent object form using Javascript. Has anyone got any ideas about how these methods need to be modified so as to work with Haml Formtastic? To add some context here's a simplified version of the problem I'm currently facing: # Teacher form (which has nested subject forms) [from my application] - semantic_form_for(@teacher) do |form| - form.inputs do = form.input :first_name = form.input :surname = form.input :city = render 'subject_fields', :form => form = link_to_add_fields "Add Subject", form, :subjects # Individual Subject form partial [from my application] - form.fields_for :subjects do |ff| #subject_field = ff.input :name = ff.input :exam = ff.input :level = ff.hidden_field :_destroy = link_to_remove_fields "Remove Subject", ff # Application Helper (straight from Railscasts) def link_to_remove_fields(name, f) f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)") end def link_to_add_fields(name, f, association) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(association.to_s.singularize + "_fields", :f => builder) end link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)} \")")) end #Application.js (straight from Railscasts) function remove_fields(link) { $(link).previous("input[type=hidden]").value = "1"; $(link).up(".fields").hide(); } function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g") $(link).up().insert({ before: content.replace(regexp, new_id) }); } The problem with implementation seems to be with the javascript methods - the DOM tree of a Formtastic form differs greatly from a regular rails form. I've seen this question asked online a few times but haven't come across an answer yet - now you know that help will be appreciated by more than just me! Jack

    Read the article

  • formtastic weird month name display

    - by Alexey Poimtsev
    Hi, i'm using formtastic, all is ok, but strange thing - on = form.input :birthdate, :as => :date it renders to something like <li><label for="profile_birthdate_2i">Month</label><select id="profile_birthdate_2i" name="profile[birthdate(2i)]"> <option value="1">114</option> <option value="2">97</option> <option value="3">110</option> <option value="4">115</option> <option value="5">108</option> <option value="6">97</option> <option value="7">116</option> <option value="8">105</option> <option value="9">111</option> <option value="10">110</option> <option value="11">32</option> <option value="12">109</option> </select> but if i'm using in semantic_form something like = form.datetime_select :birthdate it renders correctly. I've found information, that it may be caused by locale file with no translations for month names, but its so strange - why rails helpers renders month names ok, but formtastic - not :( any ideas?

    Read the article

  • How do I add custom buttons to Formtastic?

    - by jklina
    I'm using the Formtastic Rails gem in my app and its been great, but I would really like to add a second button, other than the bundled "commit" button that redirects back. I can't seem to find any information on how to add a custom button. Any information would be greatly appreciated!

    Read the article

  • formtastic - :string field value as Array and not found-s

    - by Alexey Poimtsev
    Hi, is there any possibility to send from formtastic form value of :string field like - semantic_form_for :project do |form| - form.inputs do = form.input :task_ids, :as => :string as Array? Currently value of this field is sending as String and i'd like to no parse this string in controller. Also, could you give me idea - if task with submitted id is not found - what is best way to catch this situation - validation in controller or what?

    Read the article

  • Formtastic nested model form fields (Rails 3)

    - by elsurudo
    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 |company| %> <%= company.inputs %> <% end %> <%= form.buttons %> <% end %> After scouring the web, this SEEMS like it should work. However, all I get are the user inputs. The "semantic_fields_for :company" block outputs nothing at all... Am I missing something here, or is this perhaps a Rails 3 bug to do with Formtastic?

    Read the article

  • active_admin/formtastic ignoring polymorphic associations

    - by James Maskell
    I'm currently having trouble with the form for a polymorphic association in active_admin in Ruby on Rails. I have three models set up: offices, companies and users. Both companies and users can own an office. My models are set up as follows: class Office < ActiveRecord::Base belongs_to :ownable, :polymorphic => true end class User < ActiveRecord::Base has_many :offices, :as => :ownable end class Company < ActiveRecord::Base has_many :offices, :as => :ownable end active_admin doesn't allow me to edit the owner on its forms, but does show it correctly on the index and show pages (including links to the company or user). I've tried playing with formtastic to manually create the form but have not had any luck - the "ownable" fields just get ignored and everything else renders properly. To be clear: I want to be able to edit the owner of the Office model on the new and edit fields in active_admin. Can anyone offer any help? :)

    Read the article

  • Using fields from an association (has_many) model with formtastic in rails

    - by pduersteler
    I searched and tried a lot, but I can't accomplish it as I want.. so here's my problem. class Moving < ActiveRecord::Base has_many :movingresources, :dependent => :destroy has_many :resources, :through => :movingresources end class Movingresource < ActiveRecord::Base belongs_to :moving belongs_to :resource end class Resource < ActiveRecord::Base has_many :movingresources has_many :movings, :through => :movingresources end Movingresources contains additional fields, like "quantity". We're working on the views for 'bill'. Thanks to formtastic to simplify the whole relationship thing by just writing <%= form.input :workers, :as => :check_boxes %> and i get a real nice checkbox list. But what I haven't found out so far is: How can i use the additional fields from 'movingresource', next or under each checkbox my desired fields from that model? I saw different approaches, mainly with manually looping through an array of objects and creating the appropriate forms, using :for in a form.inputs part, or not. But none of those solutions were clean (e.g. worked for the edit view but not for new because the required objects were not built or generated and generating them caused a mess). I want to know your solutions for this! :-)

    Read the article

  • Insert HTML on Radio Label on Formtastic

    - by Adrian Matteo
    I have a form that has a radio button on it (Formtastic), and It works just fine with the :collection I'm passing. The problem is I want some part of the text to be affected by some CSS, but the :collection attribute does not let me put in HTML. Here's my code: = subscription.input :plan_type_id, :as => :radio, :label => false, :wrapper_html => {:class => "plan_type"}, :collection => { @plans[:premium_yearly][:description]+number_to_currency(@plans[:premium_yearly][:amount], :precision => 2) => @plans[:premium_yearly][:value], @plans[:premium_monthly][:description]+number_to_currency(@plans[:premium_monthly][:amount], :precision => 2) => @plans[:premium_monthly][:value] } Has you may may see, I build the label I want to show with my @plans variable and the :collection attribute. Is there any way I can modify the way it renders the label, I want to put some css to some part of the label. I want something like this: = subscription.input :plan_type_id, :as => :radio, :label => false, :wrapper_html => {:class => "plan_type"}, :collection => { @plans[:premium_yearly][:description]+'<b>'+number_to_currency(@plans[:premium_yearly][:amount], :precision => 2)+'<\\b>' => @plans[:premium_yearly][:value], @plans[:premium_monthly][:description]+'<b>'+number_to_currency(@plans[:premium_monthly][:amount], :precision => 2)+'<\\b>' => @plans[:premium_monthly][:value] } Thanks in advanced.

    Read the article

  • Using fields from an association (has_one) model with formtastic in rails

    - by subprime
    I searched and tried a lot, but I can't accomplish it as I want.. so here's my problem. My models are: class User < ActiveRecord::Base has_one :profile accepts_nested_attributes_for :profile end class Profile < ActiveRecord::Base attr_accessible :user_id, :form, :title, :name, :surname, :street, :housenumber, :zipcode, :place, :phone, :mobile, :fax, :url belongs_to :user end In my view: <% semantic_form_for @user do |form| %> <%= form.inputs :login, :email, :password%> <% form.semantic_fields_for :profile do |profile| %> <%= profile.inputs %> <% end %> <%= form.buttons %> <% end %> My problem is that when I edit a person then it shows me the data on the profile. I would, that the fields from the profile even when creating a user are displayed. Thanks a lot!

    Read the article

  • Rails: ValidationReflection and Formtastic not working together

    - by user336777
    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_format_of to my config/plugins/validation_reflection.rb file (which didn't exist initially). I did this but nothing changed (i restarted the web server in between). I am not sure if it just isn't picking up on my file and loading validation_reflection.rb or if i have done something wrong. Anyone have any insights?

    Read the article

  • Formtastic with Mongoid embedded_in relations

    - by miah
    Is there any quick way to make a form for embeds_many-embedded_in relation? I have the following: class Team include Mongoid::Document field :name, :type => String embeds_many :players end class Player include Mongoid::Document embedded_in :team, :inverse_of => :players field :name, :type => String end I want to create a form for team with embedded editing for players. Seen https://github.com/bowsersenior/formtastic_with_mongoid_tutorial but "TODO" there.

    Read the article

  • Formtastic + nested categories

    - by astropanic
    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 :category, :collection => #what should go here ? end

    Read the article

  • Elegant way to reverse order Formtastic nested objects?

    - by stephan.com
    I'm presenting a list of items to the user with a field for a new item, like this: - current_user.tasks.build - semantic_form_for current_user do |f| - f.semantic_fields_for :tasks do |t| - t.inputs do = t.input :_destroy, :as => :boolean, :label => '' - if t.object.new_record? = t.input :name, :label => false - else = t.object.name Which looks lovely and works like a charm. My only problem is I want the new record at the TOP of the list, not the bottom. Is there an elegant and easy way to do this, or am I going to have to do the new element separately, or loop through the list manually?

    Read the article

  • How do I make a grouped select box grouped by a column for a given model in Formtastic for Rails?

    - by jklina
    In my Rails project I'm using Formtastic to manage my forms. I have a model, Tags, with a column, "group". The group column is just a simple hardcoded way to organize my tags. I will post my Tag model class so you can see how it's organized class Tag < ActiveRecord::Base class Group BRAND = 1 SEASON = 2 OCCASION = 3 CONDITION = 4 SUBCATEGORY = 5 end has_many :taggings, :dependent => :destroy has_many :plaggs, :through => :taggings has_many :monitorings, :as => :monitorizable validates_presence_of :name, :group validates_uniqueness_of :name, :case_sensitive => false def self.brands(options = {}) self.all({ :conditions => { :group => Group::BRAND } }.merge(options)) end def self.seasons(options = {}) self.all({ :conditions => { :group => Group::SEASON } }.merge(options)) end def self.occasions(options = {}) self.all({ :conditions => { :group => Group::OCCASION } }.merge(options)) end def self.conditions(options = {}) self.all({ :conditions => { :group => Group::CONDITION } }.merge(options)) end def self.subcategories(options = {}) self.all({ :conditions => { :group => Group::SUBCATEGORY } }.merge(options)) end def self.non_brands(options = {}) self.all({ :conditions => [ "`group` != ? AND `group` != ?", Tag::Group::SUBCATEGORY, Tag::Group::BRAND] }.merge(options)) end end My goal is to use Formtastic to provide a grouped multiselect box, grouped by the column, "group" with the tags that are returned from the non_brands method. I have tried the following: = f.input :tags, :required => false, :as => :select, :input_html => { :multiple => true }, :collection => tags, :selected => sel_tags, :group_by => :group, :prompt => false But I receive the following error: (undefined method `klass' for nil:NilClass) Any ideas where I'm going wrong? Thanks for looking :]

    Read the article

  • How to force the method for a formtastic form to be put?

    - by J. Pablo Fernández
    I have something like semantic_form_for @whatever, :url => whatever_url which generates a from with method="post" I need it to be put, I've already tried: semantic_form_for @whatever, :url => whatever_url, :html => {:method => "put"} and semantic_form_for @whatever, :url => whatever_url, :html => {:method => :put} and semantic_form_for @whatever, :url => whatever_url, :html_args => {:method => :put} with no effect. Any ideas how it's done?

    Read the article

  • HTML - Correct way of coding a checkbox with a Label.

    - by egarcia
    I've been using formtastic in order to generate HTML forms on rails applications. My question, however, is really HTML-related. Today I found a strange behaviour on the way formtastic generates checkboxes (fields of type :boolean on formtastic lingo). The rest of the fields (non-checkboxes) are generated this way: <li> <label for="my_textbox_field">My TextBox</label> <input id="my_textbox_field" type="text" ... > </li> Checkboxes, however, are enclosed inside their <label> tags completely - like this: <li> <label for="my_boolean_field"> <input id="my_boolean_field" type="checkbox" ... > This is my boolean field </label> </li> Formtastic phylosophy seems to be based on the Learning to Love Forms presentation. In effect, on slide 36 of that presentation this structure is suggested for checkboxes. I guess in the presentation itself the presenter explained why this was done, but it is not written on the slides. Can anyone tell me why enclosing checkboxes inside their <label> tag might be a good idea, as opposed to putting them outside, like with textboxes?

    Read the article

  • has_many :through formtastic multi-select field

    - by Tristan O'Neil
    I'm trying to set up a many to many relationship using the has_many :through method and then use a multi-select field to setup the relationships. I'm following this tutorial: http://asciicasts.com/episodes/185-formtastic-part-2 However for some reason the form displays a strange hex number and it changes each page refresh, I'm not exactly sure what I'm doing wrong. Below is my model/view code. company.rb has_many :classifications has_many :sics, :through => :classifications sic.rb has_many :classifications has_many :companies, :through => :classifications classification.rb belongs_to :company belongs_to :sic _form.html.erb <% semantic_form_for @company do |f| %> <% f.inputs do %> <%= f.input :company %> <%= f.input :sics %> <% end %> <%= f.buttons %> <% end %> Also here is the the form looks like it's showing the correct number of entries for the field but it is clearly not showing the correct name for the relationship.

    Read the article

  • rails HABTM versus view (formtastic)

    - by VP
    I have two models: The model NetworkObject try to describe "hosts". I want to have a rule with source and destination, so i'm trying to use both objects from the same class since it dont makes sense to create two different classes. class NetworkObject < ActiveRecord::Base attr_accessible :ip, :netmask, :name has_many :statements has_many :rules, :through =>:statements end class Rule < ActiveRecord::Base attr_accessible :active, :destination_ids, :source_ids has_many :statements has_many :sources, :through=> :statements, :source=> :network_object has_many :destinations, :through => :statements, :source=> :network_object end To build the HABTM i did choose the Model JOIN. so in this case i created a model named Statement with: class Statement < ActiveRecord::Base attr_accessible :source_id, :rule_id, :destination_id belongs_to :network_object, :foreign_key => :source_id belongs_to :network_object, :foreign_key => :destination_id belongs_to :rule end The problem is: is right to add two belongs_to to the same class using different foreign_keys? I tried all combinations like: belongs_to :sources, :class_name => :network_object, :foreign_key => :source_id but no success.. anything that i am doing wrong?

    Read the article

  • How to pre-check checkboxes in formtastic

    - by trustfundbaby
    I have a form I'm trying to set up ... Users can have many posts, and each post can have many people watching it. The Watch model is set up polymorphically as 'watchable' so it can apply to different types of models. It has a user_id, watchable_id, watchable_type and timestamps as attributes/fields. This is soley so that when people comment on a post, users watching the post can get an email about it. What I'm trying to do is show the user a list of users that they can tag on each post, which is not problem. This is what I'm using right now http://pastie.org/940421 The problem with this, is that when you go to edit an update/post ... all the checkboxes are prechecked ... I want it to pre-check only users who are currently watching the post.

    Read the article

  • cant access nested ressource 'comments' in rails 3.0.1

    - by DannyRe
    Hey, I hope you can help me. /config/routes.rb resources :deadlines do resources :comments end /model/comment.rb class Comment < ActiveRecord::Base belongs_to :post, :class_name = "Post", :foreign_key = "post_id" end /model/post.rb class Post < ActiveRecord::Base has_many :comments end When I want to visit: http://localhost:3000/posts/1/comments/new it says: undefined method `comments_path' for #<#:0x4887138 in _form.html I use 'formtastic' and the _form.html.erb looks like this: <% semantic_form_for [@comment] do |form| % <% form.inputs do % <%= form.input :content % <% end % <% form.buttons do % <%= form.commit_button % <% end % <% end %

    Read the article

  • validates_associated in production

    - by Rien
    Hi all. Imagine a simple model. class Service belongs_to :user validates_associated :user accepts_nested_attributes_for :user end Nothing special right? The validations on the associated User model trigger correctly in development mode. But don't do anything in production. I've added a validates_on_presence :user just like the docs say. This triggers when there's no User associated with the Service, but fill in one thing on the User model and nothing happens! It's driving me up the walls. Am I overlooking something? More info about the MVC: I use formtastic for the forms. Thanks!

    Read the article

1 2  | Next Page >