2018-10-22         Dominic

Cannot use specific version of bundler

I'm on Debian 9 and I'm trying to use the 1.16.3 version of bundler on a ruby on rails site. However for some reason the system insists on using the older version 1.13.6 both by default and when I explicitly specify it:To resolve this I tried completely uninstalling the 1.13.6 version:Now I'm starting to feel like I'm taking crazy pills. Is it physically possible to use the 1.16.3 version?Edit in reply to matthewd: which -a bundler finds two hits:/usr/local/bin/bundler/usr/bin/bundlerIf run with bundler -v both report to be version 1.13.6Edit in reply to Kedarnag Mukanahall...

 ruby-on-rails                     2 answers                     41 view
 2018-10-22         Gail

Passenger / REE can't find rails, it's in the $PATH, what gives?

I've got a fresh install of Ruby EE (1.8.6-20090610) and Passenger (2.2.5) on Debian Lenny. REE is installed in /opt/ruby-enterprise and it is added to the $PATH of all users through /etc/environment, and PassengerDefaultUser is set to root. The problem is when loading a rails app, the Passenger error says the rails 2.3.3 gem is missing. However it was installed with Passenger and a rails -v as root says it's there. What could be going wrong? Found the error:PassengerRuby /usr/bin/ruby1.8should have been PassengerRuby /opt/ruby-enterprise/bin/ruby [XXX]

 ruby-on-rails                     1 answers                     42 view
 2018-10-22         Valerie

Using acts_as_list and in_place_editing at the same time

I have a rails project where the the view displays a list of items. I use acts_as_list to make the list DnD orderable and in_place_editing on each item to, well, edit it.My problem is that when I DnD the items around, the item I drag automagically becomes editable when I drop it. Any tips on how I can avoid that behavior. Ideally, I'd like to make it editable by clicking a small icon next to the item, but I don't know how to make that work with this plugin.Thanks in advance. This happens because the element you are dragging has a listener on mouseup that begins the ed...

 ruby-on-rails                     1 answers                     1 view
 2018-10-22         Dana

Rails 2.3 migration issue with helpers

I'm migrating a plugin of mine that uses engines plugin. In my plugin there is a helper wich is not being recognized by rails.Does anyone knows any issue related?Thanks I got it, I must include my helpers manually, like:ActionView::Base.send :include, ResourcesHelperin init.rb file. [XXX]

 ruby-on-rails                     1 answers                     6 view
 2018-10-22         Bevis

ActiveStorage : Why not using service_url instead of blob/variant/preview url (302 redirect)?

In Rails 5.2, Active Storage gives us the ability to generate permanent urls that are redirecting to an asset, via unique signed urls at each call.html:<img src='/rails/active_storage/blobs/ey...' />server:Started GET "/rails/active_storage/blobs/eyJfcmFpbH...302 Redirected to https://bucket.amazon/image.jpg?X-Amz-Algorithm=AWS4-HMA...I am wondering about the number of HTTP requests Active Storage is adding to the monolith, one blob_url in the web page = one additional request to the monolith, in order to get the final asset url via 302 redirect. So One page with 20 i...

 ruby-on-rails                     1 answers                     91 view
 2018-10-22         Josephine

Rails Dynamic / Cascading Select dropdown list

I am a relative beginner and have been trying to get this to work.On my form I want to populate the Rooms select using Ajax once the Location has been selected (on_change).I have roughly followed this - https://kernelgarden.wordpress.com/2014/02/26/dynamic-select-boxes-in-rails-4/ - but I cannot quite get it to work.Form<%= form_for @booking do |form| %> <p> <%= form.label :booked_date %> <%= form.date_select :booked_date, order: [:month, :day, :year], start_year: 2018 %> </p> <p> <%= form.select :location_id, options_for_s...

 ruby-on-rails                     1 answers                     92 view
 2018-10-22         Truda

How to validate Rails model based on a parameter?

I have User model, and need to validate phone number attribute based on the controller param.class User < ActiveRecord::Base validates_presence_of :phone_numberendThis validation should validate phone_number in the Create action. Let's say the param I should check is params[:phone_number] you can use before_save validation, in User model you can writebefore_save :validate_phone_numberprivatedef validate_phome_number self.phone_number = /some regex/endIn self.phone_number you will get controller params by default [XXX]validate :custom_validation, :on => :cre...

 ruby-on-rails                     3 answers                     93 view
 2018-10-22         Leonard

Rails TypeError (no implicit conversion of Symbol into Integer) on a string

After setup a simple token check on the session rails spits out this TypeError (no implicit conversion of Symbol into Integer) app/controllers/sessions_controller.rb:21:in `verify_token'on this methodso, as i checked seems right.someone has any idea why this is happening on this method?def verify_token @current_user = User.find_by(auth_token: request.headers['token'] [:auth_token]) if @current_user render json: {message:"verified", status: 200} else render_unauthorized("Token failed verification") endend The problem is `request...

 ruby-on-rails                     1 answers                     94 view
 2018-10-22         Cynthia

Is preloading possible for classes from modules?

I'm using voting gem acts_as_votable. That's just for explanation, my question is wider than just a 'question about gem'. If you have any example for the same situation but another 'dressing' - there's no problem.In two words I'd like to preload votes along with posts. But it's not so easy because Vote class comes from module. So I can acces it only by calling ActsAsVotable::Vote. And doing something like @posts = Post.where(user_id: user.id).includes(:vote) leads to an error: Association named 'vote' was not found on Post; perhaps you misspelled it?QUESTION: Is there any w...

 ruby-on-rails                     1 answers                     95 view
 2018-10-22         Dana

Removed www subdomain and now app cannot locate assets

I just built a new version of my website and when I kept the old version still running at v1.domain_name.com. The new app has taken domain_name.com and www.domain_name.com. When the old version loads, it's still looking to for files at www:Request URL: https://www.domain_name.com/assets/application-ac351bca8a3fa2a33d1cb8f4c9cc40ac84207be5f2dfd46e9040019626608098.cssHow might I change that? You just need to change the asset host in the confighttps://guides.rubyonrails.org/asset_pipeline.html#cdns# config/environments/production.rbconfig.action_controller.asset_host = 'v...

 ruby-on-rails                     1 answers                     96 view
 2018-10-22         Joshua

Skipping callbacks on record create

I have a model A with an after_commit callback on create and update.class A < ApplicationRecord after_commit :update_xyz, on: [:create, :update]endA rake task is in this use case. My rake task tries to create a number of model A records, but have to skip this update_xyz callback.Is it possible to skip these callbacks while creating records? I would prefer not to add additional gems/plugins for this. If you want a way to generally have the callback run, but at specific times be able to skip it, I usually go with this pattern:class User < ActiveRecord::Base attr_ac...

 ruby-on-rails                     4 answers                     97 view
 2018-10-22         Penelope

Getting FactoryBot::DuplicateDefinitionError: Factory already registered

I am getting FactoryBot::DuplicateDefinitionError:Factory already registered:user error when I run the user spec. I want to create multiple object of user with different name and age. my user.rb in factories dir isFactoryBot.define do @users = [{display_name: 'abc', age: 25}, {display_name: 'xyz', age: 30}] @users.each do |user| factory :user do display_name user[:display_name] age user[:age] end endendis anything wrong with this code?Thanks I believe this is a good case for using FactoryBot's traits. There can ever only be one named factory, but trai...

 ruby-on-rails                     2 answers                     98 view
 2018-10-22         Pamela

How to pluralize human_attribute_name with Rails 5 and I18n?

I want to translate and pluralize an attribute name in my App.So, for the my api_key attribute, I have the translation "Clef API".I pluralize the attribute name with Mymodel.human_attribute_name(:api_key).pluralize(2) and get as a result : "Clef APIs" But in french, the plural for "Clef API" is "Clefs API"So I tried to give plural translations in my YML but it does not work and I stillget the transaltion for "One" pluralized with an 's' at the end.fr.yml :activerecord: attributes: mymodel: api_key: one: "Clef API" other: "Clefs API" Can I get Mymodel...

 ruby-on-rails                     2 answers                     99 view
 2018-10-22         Burke

Rails app. Dependency installed with yarn. How to get to the files?

I have a Rails app. I installed fullPage.js library with yarn. The library is in node_modules.How can I load the files in my app? I am trying:<link rel="stylesheet" type="text/css" href="fullpage.css" />This is not working. I get: GET http://localhost:3000/fullpage.css 404 (Not Found)I've tried to import this file in application.scss, in application.js.I've tried to put the whole path:<link rel="stylesheet" type="text/css" href="node_modules/fullpage.js/dist/fullpage.css" />or<link rel="stylesheet" type="text/css" href="/node_modules/fullpage.js/dist/fullpag...

 ruby-on-rails                     1 answers                     30 view
 2018-10-22         Jill

How to `update_all` based on a subquery in Rails

I'm trying to achieve something pretty simple in PostgreSQL the Rails way.Say you have a User model with 3 columns id, cached_segment, cached_step.Say you already have a complex query that calculates segment and query on the fly, encapsulated in a scope User.decorate_with_segment_and_step. This returns an ActiveRecord relation, same as User, but with 3 additional columns:id cached_segment cached_step segment step cache_invalid1 NULL NULL segment_1 step_1 TRUE2 segment_1 step_2 segment_1 step_2 FALSE3 ...The SQL I would like to gen...

 ruby-on-rails                     1 answers                     57 view
 2018-10-22         Polly

How to get library of devise so that it can be modified like php libraries

Getting the generated devise controller like.class Users::SessionsController < Devise::SessionsController before_action :configure_sign_in_params, only: [:create] # GET /resource/sign_in def new # super # byebug redirect_to root_url end # POST /resource/sign_in def create puts 'Login user............' super puts '..............' end # DELETE /resource/sign_out def destroy super end # protected # If you have extra params to permit, append them to the sanitizer. def configure_sign_in_params ...

 ruby-on-rails                     1 answers                     37 view

Page 1 of 1733  |  Show More Pages:  Top Prev Next Last