Tag: forms

Add custom class to form fields

Having such form <%= form_tag ‘search’, method: ‘get’, class: ‘form-horizontal’ do %> <%= label_tag :search, ‘Enter url here’ %> <%= text_field_tag :search %> <%= submit_tag ‘Get it!’ %> <% end %> Code above adds class=’form-horizontal’ for form tag. How can I add class=’form-control’ for each input field ?

Rails form building / accepts_nested_attibutes / EMPTY

A continuation of: Rails form building Survey-Questions / Response-Answers ruby-1.9.2-p180 rails 3.0.6 datamapper 1.1.0 Background – I am attempting to create a form builder from a user perspective (as opposed to something lower level in ruby/rails as a ‘formbuilder’). A user creates a form using in browser tools, specifies areas for response (e.g. fill in […]

How to show model title instead on #<Mymodel:0x000000…> in activeadmin dropdown menus?

I’ve created an association where Project has_many Tasks and Task belongs_to Project. I’ve created the form in admin/tasks.rb form do |f| f.inputs “Details” do f.input :title f.input :project end f.buttons end Now in the edit Task page I hahe a dropdown menu where I can choose the project, but the entry are #<Project:0x00000…>. How can […]

use an image for radio button label rails 4

I am trying to use the helper collection_radio_buttons to show an image as a label, and want to save the image_id to the model so that I can retrieve the url, so far i have come up with this which shows a radio button and the image_url as the label Something i have noticed already […]

Why would I get “Errno::ENOENT: No such file or directory” when viewing a Sinatra form?

I am trying to follow this tutorial: http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra/ Got stuck in “We’ll also make use of a “view file”, which allows us to split the markup for a view into a separate file. “ I have my basics.rb file running fine. And My files are stored as follows: Desktop/RubyForm/basics.rb Desktop/RubyForm/view/form.erb However, now when i go […]

Update Stripe Credit Card with Coffeescript

I finally figured out how to implement Stripes Monthly Billing using this tutorial Currently my Submit Button for both my #new_subscription form and edit form creates and sends credit card data to Stripe. But for some reason I keep getting this error when I update the Credit Card can’t convert Symbol into String app/controllers/subscriptions_controller.rb:38:in `update’ […]

How do I reference an existing instance of a model in a nested Rails form?

I’m attempting to build a recipe-keeper app with three primary models: Recipe – The recipe for a particular dish Ingredient – A list of ingredients, validated on uniqueness Quantity – A join table between Ingredient and Recipe that also reflects the amount of a particular ingredient required for a particular recipe. I’m using a nested […]

Writing Nested Form in RoR

I’m trying to write a nested form in ROR. I have two tables Employee and EmployeeInfo and both table have a column named employeeID these tables are connected with this key. What i want to do is to create a form with some input fields which should update the values into both tables. for eg […]

Saving nested model in Rails 4

Kinda new to the Rails thing, in a bit of a spot. One of the models is dependent on the other in a has_many/belongs_to association. Basically, when creating a “Post” on my application, a user can also attach “Images”. Ideally these are two separate models. When a user chooses a photo, some JavaScript uploads it […]

can't permit custom params with strong parameters

I want to permit nested custom parameters but am not sure how to access them. These are my params: params=> {“utf8″=>”✓”, “authenticity_token”=>”…”, “tracking”=>{“installation”=>”4”, “code”=>[{“1″=>”one”, “2”=>”two”}]}, “action”=>”create”, “controller”=>”admin/trackings”} According to the Strong Parameters documentation I tried some combinations like this: def tracking_params params.require(:tracking).permit(:installation, code: []) end but they are not working. What am I missing?

Ruby is the best programming language in the world - Ruby on Rails.