ruby-on-rails-4

rails 4 not using digests in asset filenames, but only in production

和自甴很熟 提交于 2021-02-07 08:01:41
问题 The bounty expires in 2 days . Answers to this question are eligible for a +100 reputation bounty. stevec wants to draw more attention to this question: I have a similar problem (albeit slightly less complicated) here: stackoverflow.com/questions/65990841/… Basically assets aren't being given their full url (with digest) in production, so they simply aren't working. The urls are generated in the controller, and image_url() doesn't seem to return the same result from the controller as it does

Formatting Excel cell from number to text in rails

落花浮王杯 提交于 2021-02-07 07:59:34
问题 I have made an application on which I have provide the feature to import the records from CSV and Excel file. I am using roo gem for it. The record added successfully but the problem is at the time of importing records from excel, it adds .0 to every field which is number. I don't want it because i have some fields like enrollment_no, roll_no, contact_no and it adds .0 to every filed like it made 23 to 23.0. I already had converted these filed to varchar in database and now i want to format

NameError: uninitialized constant CarrierWave::Storage::Fog

孤者浪人 提交于 2021-02-07 07:50:12
问题 I have tried several solution given on stackoverflow and github, but couldnt find the solution. I am using carrierwave (0.10.0) and fog-aws (0.8.1) gems for my app to upload image to S3. NameError: uninitialized constant CarrierWave::Storage::Fog from /home/pulkit/.rvm/gems/ruby-2.3.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:73:in `eval' from /home/pulkit/.rvm/gems/ruby-2.3.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:73:in `eval' from /home

Rails 4 + Devise + Rails API: undefined method 'flash'

一曲冷凌霜 提交于 2021-02-07 07:15:57
问题 I have an existing Rails 4 application which uses Devise and Omniauth . I'm trying to modifying my existing app to develop an API (I mean I will have my web app as it is and also I want an API for mobile app) but I'm having a hard luck. I'm following the steps that are listed in Rails-API under "For already existing apps" section and now I'm getting the below error undefined method `flash' for #<Devise::SessionsController:0x000000098221d0> The error pops at this line <% unless flash.blank? %>

Rails 4 + Devise + Rails API: undefined method 'flash'

瘦欲@ 提交于 2021-02-07 07:14:13
问题 I have an existing Rails 4 application which uses Devise and Omniauth . I'm trying to modifying my existing app to develop an API (I mean I will have my web app as it is and also I want an API for mobile app) but I'm having a hard luck. I'm following the steps that are listed in Rails-API under "For already existing apps" section and now I'm getting the below error undefined method `flash' for #<Devise::SessionsController:0x000000098221d0> The error pops at this line <% unless flash.blank? %>

Rails 4 + Devise + Rails API: undefined method 'flash'

喜你入骨 提交于 2021-02-07 07:12:29
问题 I have an existing Rails 4 application which uses Devise and Omniauth . I'm trying to modifying my existing app to develop an API (I mean I will have my web app as it is and also I want an API for mobile app) but I'm having a hard luck. I'm following the steps that are listed in Rails-API under "For already existing apps" section and now I'm getting the below error undefined method `flash' for #<Devise::SessionsController:0x000000098221d0> The error pops at this line <% unless flash.blank? %>

Sortable UUIDs and overriding ActiveRecord::Base

若如初见. 提交于 2021-02-06 20:00:45
问题 I'm wanting to use UUIDs in an app I'm building and am running into a bit of a problem. Due to UUIDs (v4) not being sortable because they're randomly generated, I'm trying to override ActiveRecord::Base#first, but Rails isn't too pleased with that. It yells at me saying ArgumentError: You tried to define a scope named "first" on the model "Item", but Active Record already defined a class method with the same name. Do I have to use a different method if I want to sort and have it sort

Sortable UUIDs and overriding ActiveRecord::Base

非 Y 不嫁゛ 提交于 2021-02-06 20:00:26
问题 I'm wanting to use UUIDs in an app I'm building and am running into a bit of a problem. Due to UUIDs (v4) not being sortable because they're randomly generated, I'm trying to override ActiveRecord::Base#first, but Rails isn't too pleased with that. It yells at me saying ArgumentError: You tried to define a scope named "first" on the model "Item", but Active Record already defined a class method with the same name. Do I have to use a different method if I want to sort and have it sort

Pundit policies with two input parameters

落花浮王杯 提交于 2021-02-06 15:32:32
问题 I'm pretty new with Rails and I have a problem with the following policies (using Pundit): I'd like to compare two objects: @record and @foo , as you can see here: class BarPolicy < ApplicationPolicy def show? @record.foo_id == @foo end end I don't reach to find a good way to pass a second parameter to pundit methods (@foo). I'd like to do something like: class BarsController < ApplicationController def test authorize bar, @foo, :show? # Throws ArgumentError ... end end But the Pundit

Pundit policies with two input parameters

女生的网名这么多〃 提交于 2021-02-06 15:32:09
问题 I'm pretty new with Rails and I have a problem with the following policies (using Pundit): I'd like to compare two objects: @record and @foo , as you can see here: class BarPolicy < ApplicationPolicy def show? @record.foo_id == @foo end end I don't reach to find a good way to pass a second parameter to pundit methods (@foo). I'd like to do something like: class BarsController < ApplicationController def test authorize bar, @foo, :show? # Throws ArgumentError ... end end But the Pundit