ruby-on-rails-5

HTTPS for Rails Application - InvalidAuthenticityToken

六眼飞鱼酱① 提交于 2020-01-14 12:57:07
问题 I am trying to get https to work for my rails application. When i try to do any post related activity on the application i am getting the following error. Exception `ActionController::InvalidAuthenticityToken' at /usr/local/rvm/gems/ruby-2.4.1/gems/actionpack-5.0.4/lib/action_controller/metal/request_forgery_protection.rb:195 - ActionCon troller::InvalidAuthenticityToken Exception `ActionController::InvalidAuthenticityToken' at /usr/local/rvm/gems/ruby-2.4.1/gems/actionpack-5.0.4/lib/action

Uploading via a nested form and carrierwave doesn't seem to be working

六眼飞鱼酱① 提交于 2020-01-14 12:38:49
问题 I have a Profile model and Transcript model. My Profile model looks like this: class Profile < ActiveRecord::Base has_many :transcripts, dependent: :destroy accepts_nested_attributes_for :transcripts, allow_destroy: true end Transcript model looks like this: class Transcript < ApplicationRecord belongs_to :profile mount_uploader :url, TranscriptUploader end This is my TranscriptUploader class TranscriptUploader < CarrierWave::Uploader::Base storage :fog def store_dir "uploads/#{model.class.to

Uploading via a nested form and carrierwave doesn't seem to be working

瘦欲@ 提交于 2020-01-14 12:38:06
问题 I have a Profile model and Transcript model. My Profile model looks like this: class Profile < ActiveRecord::Base has_many :transcripts, dependent: :destroy accepts_nested_attributes_for :transcripts, allow_destroy: true end Transcript model looks like this: class Transcript < ApplicationRecord belongs_to :profile mount_uploader :url, TranscriptUploader end This is my TranscriptUploader class TranscriptUploader < CarrierWave::Uploader::Base storage :fog def store_dir "uploads/#{model.class.to

1 error prohibited this book from being saved [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 11:27:28
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have been facing problem while creating new book. User is logged in but still it says: 1 error prohibited this book from being saved User must exist When i edit my book it works fine but when i try to create new book it shows .error/ This is book controller: class BooksController < ApplicationController before

Issue with upgrading to Rails 5 - before filter

╄→尐↘猪︶ㄣ 提交于 2020-01-12 07:24:20
问题 I know that before_filter is deprecated with rails. I'm not calling it but for some reason I'm getting a message that is saying I am. before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <top (required)> at /Users/intern/Desktop/Work/app/config/environment.rb:5) In that file environment.rb on line 5 I'm not calling before filter but this line Rails.application.initialize! Why would it be saying that a before filter is being used when it's not

Rails 5 api only app with home page

帅比萌擦擦* 提交于 2020-01-12 04:53:19
问题 I have generated a rails 5 api application. But I want my app with home page. For that I generated a home controller and added view file i respective views/home/index.html.erb But when I tried accessing it I am getting below response Started GET "/home/index" for 127.0.0.1 at 2016-07-14 11:14:03 +0530 Processing by HomeController#index as HTML Completed 204 No Content in 0ms Started GET "/home/index.js" for 127.0.0.1 at 2016-07-14 11:14:20 +0530 Processing by HomeController#index as JS

Why does Rails fails to boot with “Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)”?

徘徊边缘 提交于 2020-01-12 02:52:08
问题 After bundle update my Rails app fails to boot with: Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError) 回答1: They've changed things with the latest version of sprockets. This error comes up because you don't have a manifest.js created. You need to create one, and add in a few lines to make sure things are working. Easy Steps To Solve the Problem: Create the manifest.js file $ mkdir -p app/assets/config $ touch app/assets/config

RAILS: Nested attributes in new method with existing record

旧城冷巷雨未停 提交于 2020-01-11 05:14:09
问题 I have models: Frame.rb belongs_to :manufacturer, foreign_key: 'model' accepts_nested_attributes_for :manufacturer, :reject_if => proc { |obj| obj.blank? } When i try to create new Frame with existing manufacturer i get an error: Frame.new({name: 'Name of the frame', manufacturer_attributes: {id:2}}) Error: Couldn't find Manufacturer with ID=2 for Frame with ID= 回答1: The problem is that Frame.new is a new record, when ActiveRecord reaches the parameter manufacturers_attributes it performs a

Rails 5 console not working when deploying with Capistrano

删除回忆录丶 提交于 2020-01-11 03:18:28
问题 I amm using Rails 5, and I have half way deployed my app through Capistrano on server. due to specific need to loadschema, i ssh in and cd into the release/### directory and tried to run rails --version # came out 5.0.3beta bundle # works, everything installed rails c # but this fail running rails db:migrate also failed. it seems to return rails generic help as like my directory isn't a rails directory. i tried deleting bin folder, but still the same. anyone know what could be wrong? thank

ActionCable on AWS: Error during WebSocket handshake: Unexpected response code: 404

狂风中的少年 提交于 2020-01-09 10:08:45
问题 We are attempting to deploy DHH's simple Rails 5 chat example to a single, self contained EC2 instance on AWS. Code is available here: https://github.com/HectorPerez/chat-in-rails5 We used Elastic Beanstalk to spin up a single instance thus: eb create dev-env -p “64bit Amazon Linux 2015.09 v2.0.4 running Ruby 2.2 (Puma)” –single -i t2.micro --envvars SECRET_KEY_BASE=g5dh9cg614a37d4bdece9126b42d50d0ab8b2fc785daa1e0dac0383d6387f36b This is a minimal installation, so there is no Elasticache, and