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

undefined method `validate_presence_of' for RSpec::ExampleGroups::User::Validations

I am trying to pass my Model Specs for validation but i am not able to get them to pass. I have placed all the validation rules in my Model file as well app/model/user.rb class User < ActiveRecord::Base has_many :friendships has_many :friends,…
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
7
votes
1 answer

How to add routes for a new template?

I am new in Ruby and Rails and little bit confused about rendering and adding routes for a new template. I have following link_to tag <%= link_to 'Show Current State', simulation, :action => :current_state, :class => 'btn…
Mike phawn
  • 73
  • 5
7
votes
1 answer

Omniauth devise Authentication failure! csrf_detected:

I got the Authentication failure! csrf_detected: so that I couldn't login with omniauth. I followed this tutorial and I found similar issue here, But there are no luck for my problem till now. Any idea for fixing the error ? Thanks E,…
newBike
  • 14,385
  • 29
  • 109
  • 192
7
votes
1 answer

Rails 4 + Rolify Gem: User roles aren't being updated via UI

I have an edit view that allows me to update roles for a particular user. I've included the code below, however, just to give you an idea, when I uncheck the boxes on the page, my puts statements in my controller correctly picks up that the role…
Ryan Drake
  • 359
  • 3
  • 17
7
votes
2 answers

Rails time select to show only hour?

How do I make Rails time select to show only the hour part without the minutes? Basically what I want is to show a time filter with start_time and end_time and use Ransack gem to filter the query. # db create_table "schedules" t.time "start_time" …
hsym
  • 4,217
  • 2
  • 20
  • 30
7
votes
1 answer

Rails 4 gmaps4rails - How to include a link to a "show" view in marker infowindow in gmaps4rails gem

I have gotten gmaps4rails working in my rails 4 app, with markers for my lcoation, and I would like to include a link in each location's marker to each location's individual show view. My spaces controller index action looks like this: def index …
7
votes
2 answers

Stubbing method in ActionDispatch::IntegrationTest

I'm doing some stripe integration tests and I would like to stub/mock a few endpoints. I'm attempting to do it like this: Stripe::Charge.stubs(:retrieve).returns({:balance_transaction => 40}) but I'm getting the following: NoMethodError: undefined…
Msencenb
  • 5,675
  • 11
  • 52
  • 84
7
votes
1 answer

how to search and sort data but exclude prefix words in sql

I am using Ruby on Rails and pg_search gem for full-text search function using PostgreSQL database in my project. Currently, I have a list hospitals with name like: Hospital A Hospital C Hospital D Hospital B A When I make search, I would like the…
Thanh
  • 8,219
  • 5
  • 33
  • 56
7
votes
1 answer

How to to run eslint on *.js.erb files?

I'd like to lint the files in my rails project (ideally, in my editor while making edits) via eslint, but I am currently unable to lint files that are pre-processed with ERB. How can I include *.js.erb files in the linting process?
Austin York
  • 808
  • 2
  • 10
  • 24
7
votes
1 answer

Better practice for huge size of table on Ruby on Rails 4 / ActiveRecord

fBetter practice for huge size of table on Ruby on Rails 4 / ActiveRecord How could I partition a big table in the postgreSQL with Active Record on Rails 4 I prefer PostgreSQL or other RDBMS, because I tried it in MongoDB. It is really slow on…
newBike
  • 14,385
  • 29
  • 109
  • 192
7
votes
1 answer

Join table comment in rails 4 migration

I'm pretty new on rails 4 and I'm not really sure about how should be my join_table. I've done the migration rails g migration CreateJoinTableQuestionSubTopic question sub_topic And I get this file class CreateJoinTableQuestionSubTopic <…
7
votes
1 answer

Custom views and assets for tenants in a multi-tenant rails app?

When using a rails engine, overriding views is as easy as creating new views in the right folder. But when creating a multi-tenant rails app where all tenants reside in the same app (they don't use an engine), how can one override views for…
Jacob
  • 6,317
  • 10
  • 40
  • 58
7
votes
1 answer

rails 4 turbolinks multiple bindings

There are similar questions to this, but they all seem to be caused by javascript tag in body, in my case mine is in the head. I also cant move my js outside of the page change block (I don't think I can at least) I am following rails convention by…
Joelio
  • 4,621
  • 6
  • 44
  • 80
7
votes
1 answer

IO::EAGAINWaitReadable: Resource temporarily unavailable - read would block

I get the following error when I try to use the method "read_nonblock" from the "socket" library IO::EAGAINWaitReadable: Resource temporarily unavailable - read would block But when I try it through the IRB on the terminal it works fine How can I…
tisokoro
  • 265
  • 1
  • 3
  • 13
7
votes
3 answers

Bad wkhtmltopdf's path for wicked_pdf and wkhtmltopdf

I am using two Gems to convert HTML to PDF. Using "https://github.com/mileszs/wicked_pdf" gem 'wicked_pdf' gem "wkhtmltopdf-binary" /initializer/wicked_pdf.rb WickedPdf.config = { exe_path => "xxxxxxxxxxxxxxxxxxx" } What path should I use for…
KKB
  • 558
  • 4
  • 18