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

How do I use custom delayed_job jobs with ActiveJob?

I'm using DelayedJob and I'd like to update my Rails 4.2 app to use ActiveJob. The problem is that I have a bunch of custom jobs that look like this: AssetDeleteJob = Struct.new(:user_id, :params) do def perform # code end # more methods…
7
votes
1 answer

Create a JSON having dynamic hash keys with jbuilder

Here I want to output json with dynamic group name rather than word group @tickets.each do |group, v| json.group { json.array! v do |ticket| json.partial! 'tickets/ticket', ticket: ticket end} end Where @ticket is a hash like this…
Adnan Ali
  • 2,890
  • 5
  • 29
  • 50
7
votes
3 answers

ajaxSubmit uploadprogress always return 100

I am trying to make a progress bar to show the user how much of the file is uploaded, I am using ajaxSubmit and uploadprogress function, however this function doesn't update it just gives me 100 and that is it: Here is my JS code: function…
7
votes
1 answer

Should I use rails 4.2 add foreign_key or not?

By release of rails 4.2 add_foreign_key method was introduced. As far as I understand it is used as combo of migration with model:references and add_index. Let's say I only use PostreSQL. (add_foreign_key is limited to MySQL and PostreSQL). Should…
Filip Bartuzi
  • 5,711
  • 7
  • 54
  • 102
7
votes
1 answer

Rails4 template error in mailer in production

On in my production env. I keep getting this error: ActionView::Template::Error: undefined method `protocol' for nil:NilClass I can't figure out where this error are in my template, can anybody help me figure this out? CODE UPDATE Complete code:…
7
votes
2 answers

Rendering page with HUGE amount of HTML

I'm creating a website that has a huge amount of HTML (many thousands of div elements). There's no real way to get away from having all these div elements and it's making the site load very slow (7-12 seconds). I've tried putting caching on the…
Holger Sindbaek
  • 2,278
  • 6
  • 41
  • 68
7
votes
2 answers

How to get Active Admin to work with Pundit after login

I've added the configuration pundit addapter authorization to my application config.authorization_adapter = ActiveAdmin::PunditAdapter When I login with the admin@example.com credentials I'm getting this error. Pundit::NotDefinedError in…
user3787971
  • 457
  • 4
  • 22
7
votes
3 answers

How do I know if I'm using rbenv

After reading about Ruby gems and having no idea what rbenv or RVM was, I figured I should probably have one of the two. I tried installing rbenv using Homebrew however it told me I had already installed rbenv. I always seem to have problems adding…
user3765580
7
votes
1 answer

POST request using CURL for Rails App

This question has been asked by many of users and I have tried all solutions but none of them have worked for.for ex: This Question here curl json post request via terminal to a rails app but still the same result. I am trying to POST data through…
Abhinay
  • 1,796
  • 4
  • 28
  • 52
7
votes
2 answers

Ruby on rails workflow engine (like IBM WorkFlow)

Is there any workflow imlementation in RoR? Several years i developed and supported a IBM Lotus Notes enterprise apps with IBM WorkFlow. This software provides possibility to draw business process scheme (e.g. someone creates document and send it to…
Stepan Yudin
  • 470
  • 3
  • 19
7
votes
1 answer

How can I use before validation callback with form object in Rails 4?

I have a Service model/table and its registration form. In the form I have almost all the Service's fields, but some of them I want to set a value, automatically, before validate the service object. Example: -- Service Controller # create…
imtk
  • 1,510
  • 4
  • 18
  • 31
7
votes
3 answers

Rails: drawbacks of using Sass's @import instead of *=require

I decided to use Sass's @import instead of Sprocket's *=require. I have this in application.scss: @import 'normalize'; @import 'font-awesome'; @import 'variables'; and this in blog.scss: @import 'application'; This way I have separate stylesheets…
Stephan
  • 137
  • 1
  • 8
7
votes
1 answer

How to create index on LOWER("users"."username") in Rails (using postgres)

I have a sequential scan occurring in my UsersController#create action. SELECT ? AS one FROM "users" WHERE (LOWER("users"."username") = LOWER(?) AND "users"."id" != ?) LIMIT ? Explain plan 1 Query planLimit (cost=0.00..3.35 rows=1 width=0) 2 Query…
7
votes
2 answers

Postgres Common Table Expression query with Ruby on Rails

I'm trying to find the best way to do a Postgres query with Common Table Expressions in a Rails app, knowing that apparently ActiveRecord doesn't support CTEs. I have a table called user_activity_transitions which contains a series of records of a…
Davor
  • 1,227
  • 4
  • 15
  • 31
7
votes
2 answers

Is it possible to DRY up yaml?

I am using Rails' 4.1.4 YAML locale files to store some translations, for example: en: words: en: passport: "passport" ticket: "ticket" train: "train" de: words: en: passport: "passport" ticket: "ticket" …
Epigene
  • 3,634
  • 1
  • 26
  • 31
1 2 3
99
100