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
39
votes
3 answers

How to update ruby in windows

I downloaded ruby trhrough the rails installer but i now want ruby 2.0.0 and already downloaded it. how do i update my ruby because whe i do ruby -v it still comes up as ruby version 1.9.3.
user2202706
  • 497
  • 1
  • 4
  • 5
38
votes
2 answers

Change the default value for table column with migration

I try to change the default column value from false to true. But when I run rake db:migrate VERSION=904984092840298 I got the following ERROR. StandardError: An error has occurred, this and all later migrations…
38
votes
1 answer

jbuilder vs rails-api/active_model_serializers for JSON handling in Rails 4

I have started to begin with Rails 4. While working with handling of JSON format data, I found we can use rails/jbuilder and works well. However, When I was taking Codeschool's Rails 4 Pattern, they mentioned gem called active_model_serializers.…
38
votes
4 answers

Rails 4.1 Mailer Previews and Devise custom emails

I have a brand new Rails 4.1.1 app where I'm customizing the Devise emails. I want to have them displayed on the new Rails email preview feature so I did the following: 1) Added the following snippet to my config/development.rb…
rodrigoalvesvieira
  • 7,895
  • 15
  • 63
  • 84
38
votes
8 answers

ActiveRecord::AdapterNotSpecified database configuration does not specify adapter

When I use heroku open my web app works fine but when I'm using rails s (localhost) I am running into this error: ActiveRecord::AdapterNotSpecified database configuration does not specify adapter Why is this? This is my database.yml # PostgreSQL.…
user3408293
  • 1,377
  • 6
  • 18
  • 26
38
votes
6 answers

Google analytics with rails 4

I am having a bit of difficulty implementing google analytics to my rails 4 project. I included the tracking code to the bottom of my layouts file and have even tried to remove turbolinks as suggested here however i google is still unable to detect…
Joshua
  • 805
  • 1
  • 8
  • 18
37
votes
3 answers

Why is safe navigation better than using try in Rails?

I'm reading this. What's the benefit of using this: user&.address&.state over user.try(:address).try(:state) I still don't get it.
Jwan622
  • 11,015
  • 21
  • 88
  • 181
37
votes
2 answers

How to disable adding ".self." in Sprockets 3.0

Even if config.assets.digest = false is set Sprockets 3.0 keep adding .self. to all static files: application.css becomes application.self.css?body=1 How to disable adding self? It is needed for correct browsersync work.
Dmitrii Dushkin
  • 3,070
  • 4
  • 26
  • 37
37
votes
1 answer

What is the best way to use Redis in a Multi-threaded Rails environment? (Puma / Sidekiq)

I'm using Redis in my application, both for Sidekiq queues, and for model caching. What is the best way to have a Redis connection available to my models, considering that the models that will be hitting Redis will be called both from my Web…
Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243
37
votes
3 answers

can't connect localhost:3000 ruby on rails in vagrant

I tried to connect localhost:3000 in windows rails server is running in vagrant(ubuntu 14.10) portforwarding is done when, I tried lynx 127.0.0.1:3000 in ubunutu, it works but, in windows, I can't connect localhost:3000, 127.0.0.1:3000 too just…
Henry
  • 1,257
  • 1
  • 9
  • 13
37
votes
5 answers

Rails 4 Error R14 on Heroku (Memory Quota Exceeded)

I have been getting the (apparently common) Error R14, not sure when it started but noticed after installing the Papertrail add-on. I also added oink after seeing others mentioning it. I have tried everything others have tried in other SO questions…
thecrentist
  • 1,241
  • 2
  • 19
  • 28
37
votes
1 answer

What does before_action returning false do in Rails 4?

I am reading the "Agile Web Development with Rails 4", on pag. 338 it says: [...] Callbacks can be passive, monitoring activity performed by a controller. They can also take a more active part in request handling. If a before action callback…
zer0uno
  • 7,521
  • 13
  • 57
  • 86
37
votes
3 answers

Tell Vagrant the ip of the host machine

I am using a vagrant box as a development machine for a project with an odd dependency I can only seem to install on ubuntu. I created my database and have my app code on my host computer, and I share them with the vagrant instance through the NFS…
jstim
  • 2,432
  • 1
  • 21
  • 28
37
votes
6 answers

before_destroy callback not stopping record from being deleted

I am trying to prevent a record from being destroyed if there are children. class Submission < ActiveRecord::Base has_many :quotations, :dependent => :destroy before_destroy :check_for_payments def quoted? quotations.any? end def…
chell
  • 7,646
  • 16
  • 74
  • 140
36
votes
8 answers

rails rbenv: rails: command not found

I have recently moved from RVM to Rbenv and when attempting to execute rails I am getting an error like the one below Pauls-Air:~ $ rails rbenv: rails: command not found The `rails' command exists in these Ruby versions: 2.1.2
Boss Nass
  • 3,384
  • 9
  • 48
  • 90