ruby-on-rails-4.2

respond_with alternatives in rails 4.2 for backbone

你。 提交于 2019-12-05 18:31:22
In rails 4.2 respond_with and respond_to have been moved to the responders gem. I've read that this is not the best practice. I use backbone.js for my app. For render all users in controller I use: class UsersController < ApplicationController respond_to :json def index @users = User.all respond_with @users end end What are the alternatives? It's only respond_with and the class level respond_to that have been removed as indicated here . You can still use the instance level respond_to as always class UsersController < ApplicationController def index @users = User.all respond_to do |wants| wants

Rails 4.2.0.beta2 - Can't connect to LocalHost?

允我心安 提交于 2019-12-05 09:39:45
I installed Rails 4.2.0.beta2 per the instructions in RailsTutorial.org 3rd Edition (the one that just came out). I'm not using the cloudIDE and am instead using Ubuntu Trusty 32 via Vagrant on a Windows 7 host with RVM. Did rails _4.2.0.beta2_ new hello_app and then pasted in his gemfile sample . After that, I ran: $ bundle install $ rails s Server starts fine, however when I try to connect to localhost:3000 I get "Server Not Found" Weirder still, I have a couple other Rails starter projects I've been tinkering with that use Rails 4.0.3 and 4.1.6 and I'm able to connect to the server there

Installing Rails 4.2.0.beta1 - Unresolved dependency found during sorting

六眼飞鱼酱① 提交于 2019-12-05 04:46:35
I've attempted to install Rails 4.2.0.beta1 ( released Aug 20, 2014 ). I get an error "Unresolved dependency found during sorting." Here are the details: $ ruby -v ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] $ gem -v 2.4.1 $ gem install rails --pre ERROR: While executing gem ... (Gem::DependencyError) Unresolved dependency found during sorting - activesupport (>= 4.0) (requested by sprockets-rails-3.0.0.beta1) How can I install Rails 4.2.0.beta1? geekdev This issue has been fixed on RubyGems. Upgrade to at least 2.4.4 Have a look at this GitHub issue for more information. You

Redirect same page to different language with Globalize & Friendly_id

做~自己de王妃 提交于 2019-12-05 04:16:55
I've been scratching my head for the last few hours, looking for an answer but I can't find it anywhere. My gem file: # Use globalize for translating models gem "globalize", github: "ncri/globalize" # for Rails 4.2 gem 'globalize-accessors', '~> 0.1.5' # Use friendly_id for slugs gem 'friendly_id', '~> 5.1.0' gem 'friendly_id-globalize', '~> 1.0.0.alpha1' Here's the situation: I have two languages "en" and "fr" 2 models : pages and pages_translations pages has a slug column, pages_translations also has a slug column. if I view the page -> en/pages/slug-en, it works. if I view the page -> fr

Installing Rails 4.2.0.beta1 – Bundler could not find compatible versions for gem “sprockets-rails”

冷暖自知 提交于 2019-12-05 01:17:17
I've attempted to install Rails 4.2.0.beta1 ( released Aug 20, 2014 ). I get an error Bundler could not find compatible versions for gem "sprockets-rails" . Here are the details: $ bundle update rails Fetching gem metadata from https://rubygems.org/......... Fetching additional metadata from https://rubygems.org/.. Resolving dependencies... Bundler could not find compatible versions for gem "sprockets-rails": In Gemfile: sass-rails (~> 4.0.3) ruby depends on sprockets-rails (~> 2.0) ruby rails (= 4.2.0.beta1) ruby depends on sprockets-rails (3.0.0.beta1) How can I install Rails 4.2.0.beta1?

RangeError for simple integer assignment in Rails 4.2.0 that should be caught by validation

余生长醉 提交于 2019-12-05 00:28:51
* UPDATE: this is now fixed in 4.2.stable and 4.2.1 * in Rails 4.2.0 (and current 4.2.stable), the ensure_in_range method happens before AR validation, yielding a RangeError if I do something as simple as @obj.threshold = 10_000_000_000 on a column with a postgres type integer threshold | integer | it yields RangeError: 10000000000 is out of range for ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer with limit 4 from .../2.0.0-p598/lib/ruby/gems/2.0.0/bundler/gems/rails-62e9e61f2d1b/activerecord/lib/active_record/type/integer.rb:41:in `ensure_in_range' which is true! but tell that to

Why doesn't Rails autoload classes from app/services?

我怕爱的太早我们不能终老 提交于 2019-12-04 14:56:15
问题 I'm working on a Rails 4.2 app and have just added app/services/fetch_artists.rb to the structure. Inside this file, I have defined a class FetchArtists; end . When trying to run rails r 'FetchArtists' it gives me a NameError: uninitialized constant FetchArtists . I've tried looking at ActiveSupport::Dependencies.autoload_paths and indeed, app/services is not there: /.../app/assets /.../app/controllers /.../app/helpers /.../app/jobs /.../app/mailers /.../app/models /.../app/controllers

Rails - Distinct ON after a join

做~自己de王妃 提交于 2019-12-04 13:28:05
问题 I am using Rails 4.2 with PostgreSQL. I have a Product model and a Purchase model with Product has many Purchases . I want to find the distinct recently purchased products. Initially I tried: Product.joins(:purchases) .select("DISTINCT products.*, purchases.updated_at") #postgresql requires order column in select .order("purchases.updated_at DESC") This however results in duplicates because it tries to find all tuples where the pair ( product.id and purchases.updated_at ) has a unique value.

mongodb connection refused docker-compose

半腔热情 提交于 2019-12-04 05:21:29
The dockerfile consists as:- FROM ruby:2.2.3-slim MAINTAINER Milan Rawal <milan@gmail.com> RUN apt-get update && apt-get install -qq -y build-essential nodejs libmagickcore-dev imagemagick libmagickwand-dev libxml2-dev libxslt1-dev git-core curl htop --fix-missing --no-install-recommends ENV INSTALL_PATH /air_scout RUN mkdir -p $INSTALL_PATH WORKDIR $INSTALL_PATH COPY Gemfile Gemfile RUN bundle install COPY . . RUN bundle exec rake RAILS_ENV=production SECRET_TOKEN=f6801f0744ff2e86b0baa542fc55075b5b79c922c518e34484cfe6a6c2149510973fa6c90d36c05907f8bf9114b6b33594f3630810b332ef3717b8b8f4f04b1f

Setting a default queue for ActionMailer deliver_later?

孤者浪人 提交于 2019-12-04 00:07:06
You can specify which queue to use when calling deliver_later in an ActionMailer by adding :queue as optional argument, e.g.: Notifier.welcome(User.first.id).deliver_later(queue: "low") Is there a way to do this in a general way, for all ActionMailers? To set the default ActionMailer queue? mrstif Before Rails 5 Looking through Rails' source code you can see that they already set the default queue name as ' mailers '. Still, if you want to change that default you can always override it by including the following code in an initialiser or loaded lib file: class ActionMailer::DeliveryJob queue