ruby-on-rails-5

application.css not in asset pipeline

六月ゝ 毕业季﹏ 提交于 2019-12-24 19:08:22
问题 I know this is a old question but no amnswer is fixing my problem. Im new to Ruby on Rails and just created project with a postgres database just to be able to upload the project to Heroku. When i start the rails server im getting the error "application.css is not present in the asset pipeline." Im using bootstrap 4 gem and this requires that you rename the applications.css to application.scss. I dont know what is wrong. I really tried every answer that is on stackoverflow without any success

undefined method or my Active Record mistakes

て烟熏妆下的殇ゞ 提交于 2019-12-24 18:13:27
问题 Sorry if my problem will be silly but Rails are new to me. I made two models and two controllers. My problems were started after I made second model and added reference to the first one. class SentencesController < ApplicationController before_action :find_story def create @sentence = find_story.sentences.build(sentence_params) if @sentence.save flash[:success] = "You wrote the continuation!" render 'stories/show' else render 'stories/show' end end private def sentence_params params.require(

How to omit empty rows using last_row in Roo Rails

青春壹個敷衍的年華 提交于 2019-12-24 17:04:28
问题 I have a spreadsheet of members designed as below: My aim is to upload some columns and exclude others. In this case, I wish to upload only the name , age and email and exclude the others. I have been able to achieve this using the slice method as shown below: def load_imported_members spreadsheet = open_spreadsheet spreadsheet.default_sheet = 'Worksheet' header = spreadsheet.row(1) (2..spreadsheet.last_row).map do |i| row = Hash[[header, spreadsheet.row(i)].transpose] member = Member.find_by

How to omit empty rows using last_row in Roo Rails

若如初见. 提交于 2019-12-24 17:03:53
问题 I have a spreadsheet of members designed as below: My aim is to upload some columns and exclude others. In this case, I wish to upload only the name , age and email and exclude the others. I have been able to achieve this using the slice method as shown below: def load_imported_members spreadsheet = open_spreadsheet spreadsheet.default_sheet = 'Worksheet' header = spreadsheet.row(1) (2..spreadsheet.last_row).map do |i| row = Hash[[header, spreadsheet.row(i)].transpose] member = Member.find_by

Password validation fails in two opposed scenarios

不羁岁月 提交于 2019-12-24 12:15:00
问题 I am working through the Ruby on Rails Tutorial by Michael Hartl and have generated an interesting dilemma. I will have done something wrong, so I need your help finding the issue. The issue surrounds the validation of a password property within a User model. The initial validation of this property was: validates :password, presence: true, confirmation: true, length: { minimum: 6 } This requires a minimum length of the password and is designed to satisfy the situation where a new user creates

Rails 5 - Create vanity route for each instance of model

萝らか妹 提交于 2019-12-24 10:17:09
问题 I know there has to be a cleaner way of doing this but I haven't written code in a while and am drawing a blank. I have a model called Link that has a Title, Slug and Destination. Destination is the location to redirect (mydomain.com/instagram would redirect to my instagram account). Slug is to customize the slug for friendly_id. This is the code in my routes.rb and it works but it feels gross. Link.all.each do |link| get "/#{link.slug}", to: 'links#show', :id -> link.id end Is there a better

Video isn't of allowed type (allowed types: video/mp4), Shrine, Rails

拟墨画扇 提交于 2019-12-24 09:58:51
问题 I'm trying to validate my videos to only allow .mp4 videos to be uploaded. I'm using Shrine to do this. Videos upload no problem without validations, but if I add the validation code the error displays: Video isn't of allowed type (allowed types: video/mp4) Here is my code: video_uploader.rb require "streamio-ffmpeg" class VideoUploader < Shrine plugin :processing plugin :versions plugin :determine_mime_type plugin :cached_attachment_data plugin :remove_attachment plugin :add_metadata add

Rails 5 : NoMethod Error - Undefined Method Paginate

倖福魔咒の 提交于 2019-12-24 09:51:59
问题 I have a JSON API based on Rails 5. I have a method that brings list of all the products for one particular company, which I want to paginate so that not to bring up all the data at once. For this I came across two gems, namely will_paginate and api-pagination . After running bundle install and restarting the server, I'm still getting the following error : NoMethodError (undefined method `paginate' for #<Api::V1::ProductsController:0x007fb25404db30>) The Products Controller : require 'roo'

User Session Authentication in Rails 5

余生长醉 提交于 2019-12-24 09:29:45
问题 I am trying to implement notification using the action cable in Rails 5. After reading the tutorial for the Action cable, which work on the session & Cookies based Authentication to receive the notification for the current logged in user. module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified_user logger.add_tags 'ActionCable', current_user.username end protected def find_verified_user if verified_user

How to disable sending cookies for a certain route only?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 08:31:09
问题 I've been searching for this information and haven't found anything. I want to disable cookies only for a particular route. Is there a way to do that? 回答1: Doesn't work in the routes file, but you can always use this in associated controllers: before_action :skip_cookies and as a private method: def skip_cookies request.session_options[:skip] = true end That should avoid including any cookies for the actions inside the controller 来源: https://stackoverflow.com/questions/53809314/how-to-disable