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

Rails 4 - Devise, guest users causes filter chain halted

I have just started working on a Rails 4 (4.2.3) app where I use Devise for user authentication. I want users to be able to play around with the app before signing upp by creating a test project and be signed in as a guest user. When the user signs…
Anders
  • 2,903
  • 7
  • 58
  • 114
7
votes
1 answer

How is something like 30.seconds.ago implemented?

I found this question here. And really curious to know the technical explanation of how something like 30.seconds.ago is implemented in Rails. Method chaining? Numeric usage as per: http://api.rubyonrails.org/classes/Numeric.html#method-i-seconds .…
7
votes
2 answers

Rails: Sidekiq cannot find the created record

I am using sidekiq to run some job after creating a record. when the job tries to find the record with the created ID, there are random cases where it raises a RecordNotFound. how can this be possible? class Person def self.test_create p =…
Yeonho
  • 3,629
  • 4
  • 39
  • 61
7
votes
1 answer

Cyclic dependency error after removing mathjax-rails

So My Gemfile currently looks like source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.4' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem…
wrongusername
  • 18,564
  • 40
  • 130
  • 214
7
votes
1 answer

Getting Error Apple push notification OpenSSL::SSL::SSLError

OpenSSL::SSL::SSLError (SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A): Integrate the library for apple push notification Houston gem. Since last two months, It was working smoothly, But now getting that error in…
7
votes
3 answers

How to send data in a post request with RestClient

I'm trying to mimic a curl request using the RestClient Ruby gem, and so far, I've been having a lot of trouble trying to send in a payload. My curl request looks something like this curl URL -X POST -u API_KEY -d '{"param_1": "1"}' I've been…
rboling
  • 717
  • 1
  • 4
  • 8
7
votes
2 answers

Make existing column unique in Rails

I have username column on users table. I could do somethig like this: rails generate migration add_username_to_users username:string:uniq but I have got username column (and I've already run migration). So how can I make username column unique?
Jensky
  • 919
  • 3
  • 12
  • 26
7
votes
1 answer

How to call method after render?

I need to do request on remote service after rendering the page My controller: after_filter :remote_action, only: :update def update @res = MyService.do_action foo, bar return render json: @res[:json], status: @res[:status] unless…
Gleb Vishnevsky
  • 547
  • 8
  • 16
7
votes
1 answer

Rails: `includes` a `has_many` relation with `limit`

I'm using Rails 4.2. I have 3 tables like this: class Collection < ActiveRecord::Base has_many :shares has_many :images, through: :shares has_many :latest_images, -> { order(created_at: :desc).limit(10) }, class_name: 'Image', through:…
ProGM
  • 6,949
  • 4
  • 33
  • 52
7
votes
2 answers

For new ActiveRecord models, why do some has_many :through associations add a (1=0) predicate and distinct clause to the sql query?

Whenever I instantiate a new ActiveRecord model (one that has not been persisted to the database) and attempt to access some various associations on the built model, the Rails query builder will sometimes: Add a (1=0) predicate to the where clause…
Kurt Mueller
  • 3,173
  • 2
  • 29
  • 50
7
votes
1 answer

How to integrate payumoney payment gateway with rails 4

Included "gem 'active_merchant_payu_in'" in Gemfile. Getting this error while bundle install /home/waheguru/.rvm/gems/ruby-2.2.0/gems/active_merchant_payu_in-0.0.1/lib/active_merchant_payu_in.rb:2:in `require': cannot load such file --…
KJ_kaka
  • 241
  • 3
  • 10
7
votes
0 answers

RailsAdmin - preventing N+1 queries via includes

Does anyone know of a way to configure that? Or another DB query optimization technique? I am using Rails 4.1.8 with RailsAdmin 0.6.8 and Mongoid 4.0.2
Dmitry Polyakovsky
  • 1,535
  • 11
  • 31
7
votes
7 answers

ActiveRecord Query to identify orphan child records

I have Post and User models. Every post belongs to a user. However, during database import, some erroneous user_ids have been entered on some posts. What would be the query to get posts whose user_ids don't refer to any user? Thanks.
7
votes
4 answers

Multiple require & permit strong parameters rails 4

In the below case, i am trying to use strong parameters. I want to require email_address, password and permit remember_me fields. But using like below it only allows the LAST line in the method Ex:- In below case it only take…
7
votes
3 answers

Expected response to be a , but was <200>

I'm trying to testing the create action in the UsersController where the user is created with a profile; then the user is redirected to the user's profile page, but i get the error Expected response to be a , but was <200>. CREATE ACTION…
Opy Osegs
  • 197
  • 1
  • 1
  • 13