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

Share data between ActiveJob and Controller

Every n seconds application is requesting a remote JSON file that provides live prices for securities in the Trading system. JSON has a block with the data I need (marketdata) and a block with the current dataversion(version and seqnum). Right now…
potashin
  • 44,205
  • 11
  • 83
  • 107
7
votes
1 answer

ActiveAdmin Nested Form multiple select

I'm trying to get the product_suppliers to update via the product form. The form displays all suppliers in the supplier table but it doesn't update the join table. Not sure where the error lies. Index and show show correct details but edit is not…
7
votes
3 answers

Rails 4 Method Not Allowed after Upgrading from Rails 3

I've got an existing codebase that I'm attempting to upgrade from Rails 3.2 to Rails 4.0 I have controller called assets_controller with a 'create' method and I have a an entry in my routes file: resources :assets Using jQuery for ajax on the front…
acolchagoff
  • 1,926
  • 3
  • 18
  • 30
7
votes
1 answer

How do I search against an object's virtual attribute with pg_search?

I have a class Node that I have setup acts_as_taggable on, so I can add user_tags to any node. I also have a method on my Node model that will look up the actual User records for all the users in the user_tag_list. Here is an illustration: [32]…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
7
votes
2 answers

how to manually change record in heroku database

I have a rails app hosted in heroku. I have a Questions table with a content column. The content column contains the word of a question. So for example if you queried. Question.first.content, you would get "Hello, how are you?". I have 8 questions…
user3266824
  • 1,233
  • 2
  • 14
  • 27
7
votes
2 answers

Locale not switching in Rails 4

My Rails App is on rails 4.0.2 and I have a problem switching translations with the locale variable and the params[:locale] from the url scheme following the official rails guide. I have a single page website at my site. My routes for…
nuxxxx
  • 223
  • 2
  • 13
7
votes
3 answers

Rails preview update associations without saving to database

I want to preview what the model will look like when saved without currently saving to the database. I am using @event.attributes = because that assigns but does not save attributes for @event to the database. However, when I also try to assign…
7
votes
3 answers

How do I run an RSpec test on a specific line?

I have next spec file: require 'rails_helper' describe Order do it "calculates the total price of the order" do item1 = create(:item) item2 = create(:item, price: 20) order = create(:order) order.items << item1 order.items <<…
Kavachaj
  • 411
  • 1
  • 4
  • 15
7
votes
1 answer

Validate attribute's length if present

How to make validation where presence of model's attribute isn't necessary, but if it is present, attribute's length must be more than three characters?
7
votes
1 answer

Obtain S3 presigned post url with query parameters for a mobile client

I am creating an API for a backend service with Rails 4. The service needs to upload an image file to an amazon s3 bucket. I'd like to use a direct upload url, so that the clients manage the uploads to s3 and the server is not kept busy. Currently I…
peshkira
  • 6,069
  • 1
  • 33
  • 46
7
votes
1 answer

PDFkit *.css stylesheets not being applied

I am trying to convert a html page that displays images from facebook cdn to pdf using pdfkit. I am using rails 4.2, pdfkit 0.6.2 and wkhtmltopdf-binary 0.9.9.3. # Gemfile gem 'pdfkit' gem 'wkhtmltopdf-binary' # controller def generate_pdf …
Prasad Surase
  • 6,486
  • 6
  • 39
  • 58
7
votes
4 answers

Is there a way to check if part of the URL contains a certain string

Is there a way to check if part of the URL contains a certain string: Eg. <% if current_spree_page?("/products/*") %>, where * could be anything?
Adam
  • 464
  • 1
  • 4
  • 13
7
votes
4 answers

Bootstrap input-group wrapper with simple_form

I'm using simple_form with bootstrap wrappers, and can't figure out, how to do this. I want to generate input like this:
7
votes
1 answer

Ruby on Rails choosing wrong controller action

Today I came across some strange (and very inconvenient) Ruby on Rails behavior that even persistent combing of the net did not yield a satisfying answer to. Note: I translated the method and route names to be easier to read in English, and hope I…
Mike
  • 73
  • 1
  • 4
7
votes
2 answers

Rails has_many through form with additional attributes

I am attempting to create a form that allows a user to add/edit/remove locations to a campaign. All the examples I have currently found are either for HABTM forms (that do not allow the editing of additional attributes that exist in a has_many…
jamgood96
  • 141
  • 1
  • 7