ruby-on-rails-4.2

Custom URL with Paperclip and AWS S3

◇◆丶佛笑我妖孽 提交于 2019-12-13 13:07:17
问题 We're using Paperclip with the aws-sdk gem to store and display images in our Rails app: class User < ActiveRecord::Base has_attached_file :image, storage: :s3, s3_credentials: 'config/s3.yml', s3_protocol: :https, styles: { curriculum: '120x120>', medium: '600x600>', thumb: '200x200>' }, default_url: 'missing_photo.png' end If I then use <%= image_tag current_user.image.url %> in an html.erb file, I get the following HTML: <img src="https://s3.amazonaws.com/<my_bucket>/users/images/000/000

How to use url_helpers in rails 4.2?

元气小坏坏 提交于 2019-12-13 09:28:40
问题 I am trying to build some links for my datatable and been struggling with it for the past 4 hours. This is my current code: class UsersDatatable < TemplateDatatable def data users.map do |user| [ user.id, user.nome, user.email, user.provider.camelize, links(user) ] end end def links(user) html = link_to url_helpers.edit_user_registration_path(user), class: "btn btn-mini btn-info", "data-rel" => "tooltip", title: "Editar", "data-placement" => "top" do content_tag(:i, '', class: "icon-edit")

Google oauth2 with devise and omniauth processed as failure

落花浮王杯 提交于 2019-12-13 02:18:00
问题 I'm trying to configure a new rails4.2 app to authenticate against Google Oauth2. I seem to be successfully going through the process, but it's being treated as a failure. The initial authorisations seems to go well until google sends to the callback. Then it seems to be incorrectly identified as a failure. The error message given is: Could not authenticate you from Google because "Invalid credentials". I've googled for a solution, but to no avail. Is it possible to turn on additional logging

Strong parameter override for DeviseTokenAuth controller

╄→гoц情女王★ 提交于 2019-12-12 15:22:40
问题 I am using devise-token-auth gem on Rails 4.2, and I've added a field nickname to the User model. I am trying to implement this via an override of the gem controller class Users::RegistrationsController < DeviseTokenAuth::RegistrationsController before_filter :configure_permitted_parameters def update #this line never shows in the logs Rails.logger.info "I never get to run!!" super end protected # my new custom field is :nickname def configure_permitted_parameters devise_parameter_sanitizer

Setting a default queue for ActionMailer deliver_later?

给你一囗甜甜゛ 提交于 2019-12-12 08:20:39
问题 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? 回答1: 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

Rails server running but not loading in browser

主宰稳场 提交于 2019-12-12 06:18:46
问题 I I am running rails using vagrant VM and when i launch server with `rails s` It works fine and shows me that i am running server fine: => Booting WEBrick => Rails 4.2.3 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2015-08-22 17:46:42] INFO WEBrick 1.3.1 [2015-08-22 17:46:42] INFO ruby 2.2.1 (2015-02-26) [i686-linux] [2015-08-22 17:46:42] INFO WEBrick::HTTPServer#start: pid=3660 port=3000 ♥[2015-08

Rails 4.2 & Salesforce API with Restforce returning ActiveModel::ForbiddenAttributesError

爷,独闯天下 提交于 2019-12-12 04:48:48
问题 I'm trying to write a rails 4.2.0.beta2 app that will allow our organisation to interface directly with our salesforce instance. I've been following this really useful entry here. I'm nearly there, i've got my app setup in salesforce, it appears to be firing off the request ok, I can get to the login page and enter my inforamation. However I'm getting the following error upon callback. ActiveModel::ForbiddenAttributesError in SessionsController#create ActiveModel::ForbiddenAttributesError

How can I link to a nested child from outside the parent element in Rails 4?

大憨熊 提交于 2019-12-11 20:20:01
问题 Ok, my situation. I have a nested resource of resources :projects do resources :campaigns end I want to make a view with controller with resources :portfolios I want to make a <% link_to %> that listed all campaigns which I can do, but when I try to route the path i can't make it link to a campaign. Example: in my portfolios/view/index.html.erb <% @projects.each do |p| %> <% p.campaigns.each do |c| %> <div class="container" > <div> <%= link_to ( image_tag c.image_camp.url(:thumb)), p %> </div

Store accessor issue : Can't read old already stored json object serialized ( hash ) values in mysql database in Rails 4

孤街醉人 提交于 2019-12-11 12:56:09
问题 I am upgrading my application to Rails 4.2.4 from Rails 3.2.8 . I have a 'extras' attribute for a table 'editorials' which is serialized store :extras, accessors: [:attr1, :attr2, :attr3], coder: JSON #The way it is stored in **Rails 3** is --- :attr1: value :attr2: value :attr3: value #The way it is stored in **Rails 4** is {"attr1":"value", "attr2":"value", "attr3":"value"} The problem when i fetch old records created when my app is in rails 3, it is throwing me error JSON::ParserError: 795

uninitialized constant ActionController::Routing (NameError)

会有一股神秘感。 提交于 2019-12-11 12:51:41
问题 I am getting this error when trying to deploy my application on a linux server. Versão servidor: PostgreSQL 9.3.4 on x86_64-pc-linux-gnu, compiled by x86_64-pc-linux-gnu-gcc (Gentoo 4.8.1-r1 p1.2, pie-0.5.7) 4.8.1, 64-bit uninitialized constant ActionController::Routing (NameError) /home/divulgapocos/apps_rails/divulgapocos/config/initializers/new_rails_defaults.rb:14:in `<top (required)>' /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:652:in `block in load_config