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

Pundit- Index Method for Admin and Users

So, I'm trying to use the gem pundit. I'm just trying to figure out how to have an index view for users and admins. I want to render all results for an admin and only related posts for a user. I've googled and searched on github, but I'm not find…
AGirlThatCodes
  • 575
  • 7
  • 21
7
votes
6 answers

jquery-datatables-rails sort arrows not showing up in development environment

I have a new rails install. I followed the instructions on this page exactly: https://github.com/rweng/jquery-datatables-rails When I try to view a datatable, I get these errors: GET http://localhost:3000/images/sort_both.png 404 (Not Found) GET…
newUserNameHere
  • 17,348
  • 18
  • 49
  • 79
7
votes
1 answer

Rails 4.2 foreign key

Rails 4.2 newly supports adding and removing foreign keys (in migrations), like: # add a foreign key to `articles.author_id` referencing `authors.id` add_foreign_key :articles, :authors What I don't understand is: How is this add_foreign_key…
TomDogg
  • 3,803
  • 5
  • 33
  • 60
7
votes
1 answer

How to get all the associated models from ActiveRecord object?

For example I have class Order < ActiveRecord::Base has_many :shippings has_one :contact_information belongs_to :shop end How to get an array of associated objects from Order. For example Order.associations # [:shipping,…
7
votes
1 answer

No such file or directory - identify with Mini Magick

my rails app was running smoothly before I had another person re-do my front-end UI. I've been trying to resolve this error for 3 days now. Here is the error: No such file or directory - identify Extracted source (around line…
ShaunK
  • 1,181
  • 5
  • 22
  • 41
7
votes
2 answers

Can't verify CSRF token authenticity Rails 4 Ajax even when header is set

I'm really having trouble with this, and in this instance, I neither want to skip the verify_authenticity_token filter, nor change to protect_from_forgery with: :null_session. In my request method, I am setting a header with the csrf token as…
mattmattmatt
  • 965
  • 3
  • 15
  • 29
7
votes
3 answers

Rails change column type and update column values

I have a table called Users with a column Active that is type boolean. I will soon need to change the type of that column to string. I will also need to change all of the column values of Active from :true to "active" and :false to "inactive". To…
7
votes
1 answer

How to delete HSTORE keys?

I have the following migration: class CreateFoos < ActiveRecord::Migration def change create_table :foos do |t| t.hstore :foos_properties end end end In the hstore column, I have 2 keys: :foo and :bar. Is it possible to create…
7
votes
1 answer

active merchant paypal gateway security header is not valid issue

I followed this railscast to set up active merchant on a rails 4.1 app. While I try to create orders and pay, I get the error from paypal server: Security header is not valid My question: What is wrong in my set up to have that kind of error ? By…
7
votes
2 answers

Jbuilder not working with gem rails-api

I'am trying rails-api gem with jbuilder and i can't seem to make it work Here is a sample of my rails-api controller / jbuilder views Gemfile gem 'jbuilder' Controller app/controller/users_controller.rb def show @user = User.find_by(id:…
C404
  • 243
  • 4
  • 14
7
votes
4 answers

How to test method alias ruby

How to test if if method has an alias? Let's say we have Class Test class << self def a;end alias :b :a end end so far I came up with idea to write this spec: it { expect(Test.b).to receive(:a) } but I believe there is better…
Filip Bartuzi
  • 5,711
  • 7
  • 54
  • 102
7
votes
4 answers

application.css.scss not compiled on Rails 4

I felt strange that why the style not loaded, So I wrote wrong content intentionally on application.css.scss, And precompile and load the page didn't give me any error. I thought the application.css.scss file must not be loaded and…
newBike
  • 14,385
  • 29
  • 109
  • 192
7
votes
5 answers

How to make my background image appear only on one page in rails 4?

I have a background image that I can not get to stay just on one page. I have made a welcome controller with one home view to display it. I am precompiling my assets as well. The background shows up just fine, but my goal is to just show the…
dobsoft
  • 109
  • 1
  • 7
7
votes
1 answer

Rails 4 enum validation

This is the first time I'm using enums with rails 4 and I ran into some issues, have couple of dirty solutions in mind and wanted to check are there any more elegant solutions in place : This is my table migration relevant part: create_table…
Gandalf StormCrow
  • 25,788
  • 70
  • 174
  • 263
7
votes
3 answers

How to check if an attribute has a presence validation in Ruby on Rails

Is there a way to know if an attribute has a validation? Something like following: Model.attribute.has_presence_validation?
el_quick
  • 4,656
  • 11
  • 45
  • 53
1 2 3
99
100