Questions tagged [ruby-on-rails-4]

For issues specific to version 4 of Rails. If your question applies to Ruby on Rails in general, use the tag [ruby-on-rails].

Ruby on Rails 4.0, "an open-source web framework that's optimized for programmer happiness and sustainable productivity." Rails 4.0 brings a bunch of new features and improvements over older Rails versions.

See Ruby on Rails 4.0 Release Notes for more information.

Multiple sub-versions have been released, namely 4.0, 4.1 and 4.2. Questions regarding specific sub-versions of Ruby on Rails 4.0 can also be asked on the appropriate tags:

Resources

Related tags

36770 questions
7
votes
1 answer

Warning: input is a void element tag and must not have `children` or use `props.dangerouslySetInnerHTML`. Check the render method of null

I am trying to render the errors in the form if the ajax call to the form URL fails. Below is my Admin component: #app/assets/javascripts/components/admin.js.coffee @Admin = React.createClass # propTypes: -> # emailVal:…
Vipin Verma
  • 5,330
  • 11
  • 50
  • 92
7
votes
3 answers

Capybara::Poltergeist Status error, failed to reach server

I am trying to make some tests with Rspec/Capybara/Poltergeist on my Rails 4 application, Phantomjs is installed (version 2.2.1), but I always get this error : Failure/Error: visit(perfect_landing_page_path) Capybara::Poltergeist::StatusFailError:…
Delphine
  • 93
  • 1
  • 3
7
votes
3 answers

Rails - How to save a hash to the DB and using it as a hash once you pull it form the DB (not pulling it as a sting)

If I save a hash to the DB hash_value = {"1"=>"val1", "2"=>"val2", "3"=>"val3", "4"=>"val4"} @page.update(hash: hash_value) Then try and loop through each key of the hash on the page page hash = @page.hash <%= hash.each do |key, value| %> <%=…
Rob
  • 1,835
  • 2
  • 25
  • 53
7
votes
3 answers

Get image dimensions using Refile

Using the Refile gem to handle file uploading in Rails, what is the best way to determine image height and width during / after it has been uploaded? There is no built in support for this AFAIK, and I can't figure out how to do it using MiniMagick.
Chris Edwards
  • 3,514
  • 2
  • 33
  • 40
7
votes
1 answer

DRY in ActiveJob::Base

I need to use sanitization in Jobs, so i wrote method def sanitized_sql_statement(query) ActiveRecord::Base.send( :sanitize_sql_array, query ) end I have 2 different job files. Where I should place this method and how to…
Max Paprikas
  • 579
  • 6
  • 16
7
votes
2 answers

Rails 4 after_save previous_changes not working

I have an after_save callback on a model, and I'm calling previous_changes to see if an attribute (is_complete) changed. Even when the attribute changes, previous_changes returns an empty hash. Here's the callback: after_save do |record| puts…
7
votes
3 answers

How to use preloaded collection in recursive methods

I've the following self referential association: class Action < ActiveRecord::Base # self referential association has_many :action_parents has_many :parents, through: :action_parents has_many :action_children, class_name: 'ActionParent',…
gabrielhilal
  • 10,660
  • 6
  • 54
  • 81
7
votes
4 answers

rails console require cannot load such file readline

I am new to Ruby on Rails, and I install ruby by source. Ruby version is 2.3.0 and rails version is Rails 4.2.5. I can't run rails c or rails console. It giving me the following error: Running via Spring preloader in process…
James
  • 143
  • 1
  • 8
7
votes
2 answers

Devise change email does not update email

I'm trying to allow users to change their email addresses which devise uses as their unique username. Even though the update gives no errors, no change is made to the email address for the user in the database. Here are the relevant portions of…
chris
  • 1,869
  • 4
  • 29
  • 52
7
votes
0 answers

Rails 4 CarrierWave (master) and MiniMagick: change file format

I'm using Rails 4.2, CarrierWave master branch, and MiniMagick 4.3.6 (also using the CarrierWave::MiniMagick module). According to the CarrierWave Docs it is possible to change the format of a file during the upload/processing stage. However, I do…
Dan L
  • 4,319
  • 5
  • 41
  • 74
7
votes
1 answer

Rails 4: combining has_many :through association with polymorphic association

In my Rails 4 app, I have the following models: User has_many :administrations has_many :calendars, through: :administrations has_many :comments has_many :calendar_comments, through: :calendars, :source => :comments Calendar has_many…
7
votes
4 answers

ActiveAdmin Filter on postgres Array field

I added the following filter in ActiveAdmin. filter :roles, as: :select, collection Model::ROLES, multiple: true but when i choose the filter value to search the roles. it gives me following error PG::InvalidTextRepresentation: ERROR: malformed…
kashif
  • 1,097
  • 4
  • 17
  • 32
7
votes
1 answer

Correct use of protect_from_forgery in Rails app serving Web and API

I am developing a Rails 4 app that serves a mobile app through an API, and has a web UI for admins to manage the application. There's also a couple of web pages that users will see (successful e-mail confirmation and reset password). I created two…
Roma149
  • 1,401
  • 1
  • 12
  • 11
7
votes
3 answers

How should I use Rails to index and query a join table?

I have a ruby on Rails 4 app, using devise and with a User model and a Deal model. I am creating a user_deals table for has_many/has_many relationship between User and Deal. Here is the migration class CreateUserDeals < ActiveRecord::Migration …
Mathieu
  • 4,587
  • 11
  • 57
  • 112
7
votes
4 answers

js.erb file is executing two times . Ruby on Rails - private_pub

I'm working on chating module. For that I've used private_pub gem. In this module I have made three channels, but I can't mention all those here, because it'll show a very, very large page. So let's stick to one channel. I click on a link having…
Mani
  • 2,391
  • 5
  • 37
  • 81