ruby-on-rails-5

`rescue in block (2 levels) in require': There was an error while trying to load the gem 'sass-rails'. (Bundler::GemRequireError)

不打扰是莪最后的温柔 提交于 2019-12-12 04:22:22
问题 I finish to install rails 5 at my ubuntu system(16.04.2 LTS) and I'm with this error when I try to run rails server command. `rescue in block (2 levels) in require': There was an error while trying to load the gem 'sass-rails'. (Bundler::GemRequireError) Gem Load Error is: uninitialized constant Sass::Script Did you mean? ScriptError When I write bundle update, the prompt show me this message: The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for.

Gmaps is not defined

拈花ヽ惹草 提交于 2019-12-12 04:21:16
问题 I´m developing an website in ROR I am using gem 'gmaps4rails'. In localhost the map is showed, but when i put on a production server (DigitalOcean) gives me this error: Uncaught ReferenceError: Gmaps is not defined i have this script in my index.html.erb: <div id="map_show" ></div> </div> <script type="text/javascript"> handler = Gmaps.build('Google'); handler.buildMap({ provider: {}, internal: {id: 'map_show'}}, function(){ markers = handler.addMarkers(<%=raw @hash.to_json %>); handler

How do I sort on an association of a specific user?

三世轮回 提交于 2019-12-12 04:14:01
问题 I have a Profile that can be published . A profile belongs_to :user and has_many :ratings . A User has_one :profile , and has_many :ratings . A Rating belongs_to :profile && belongs_to :user . These are the schemas for the above models: Profile.rb : # == Schema Information # # Table name: profiles # # id :integer not null, primary key # first_name :string # last_name :string # created_at :datetime not null # updated_at :datetime not null # user_id :integer User.rb : # == Schema Information #

skip_before_filter for the “login” action of devise

萝らか妹 提交于 2019-12-12 04:13:17
问题 I can do this to skip calling "authenticate_user" in a certain controller where I need to: class ApplicationController before_filter :authenticate_user! end class MyController < ApplicationController skip_before_filter :authenticate_user! end I want to call skip_before_filter for "login" action of devise gem and I don't want to have to override anything else. How can I do that? 回答1: One approach is to override devise sessions controler: 1) create a users/sessions_controller.rb file: class

Rails form_for renders partial form_for to list values without submitting to DB, but now 2 submits

旧街凉风 提交于 2019-12-12 03:39:44
问题 I have a simple display - form_for an application that renders another partial with form_for for displaying education qualifications. The partial is polymorphic. So, now I have 2 submits, the main submit simply doesn't respond and partial works....why?? Please note that code works well for one record but with pressing partial form submit. Please help. <%= bootstrap_form_for @application do |f| %> <div class="panel panel-default"> <div class="panel-heading"> Education: </div> <div class="panel

agged_with(params[:skill]) ArgumentError: wrong number of arguments (given 2, expected 1)

社会主义新天地 提交于 2019-12-12 03:31:49
问题 I have issue with gem acts-as-taggable-on in Rails 5 beta 3. ​ project.rb ​: class Project < ActiveRecord::Base acts_as_taggable acts_as_taggable_on :skills end routes.rb get 'tags/:skill', to: 'projects#index', as: :skill projects_controller.rb : class ProjectsController < ApplicationController def index if params[:category] && Category.exists?(params[:category]) @category = Category.find(params[:category]) @projects = @category.projects.order("projects.created_at DESC") elsif params[:skill]

How to set two users to chat together

坚强是说给别人听的谎言 提交于 2019-12-12 03:27:27
问题 I want that if a user has ordered a meal, he can talk to the meal provider... and vice versa... Users can provide meals and order meals too, like on air bnb you can be a guest or a host (or both) Exemples: Lets say we have Bob( buyer ) who orders a meal from John( maker ) I want that John and Bob can chat together John( buyer ) orders a meal from Mike( maker ), John and Mike can chat together. conversations/index.html.erb <% @users.each do |user| %> <%= link_to user.full_name , conversations

Rails 5 - NoMethod Error - undefined method

那年仲夏 提交于 2019-12-12 02:16:06
问题 In the app I am building to learn Rails, I have a polymorphic relationship between the model "TAG" and the models "ANNOTATION" and "DOCUMENT". Similar to Article and Comment models. Create and destroy of tags is working. Now, I want to update the tags and run into a no method error I don't understand. Tried many alternatives (e.g. using <%= link_to tag.content, [object, tag]... with the form <%= simple_form_for object.tag ... ). The form is called using: <% object.tags.each do |tag| %> <%

Why isn't my production Rails server resolving constants?

五迷三道 提交于 2019-12-12 01:36:37
问题 We just updated to Rails 5. All tests now pass. I'm able to spin up a web server and everything appears to work. But over on the production server, some URLs give an error like this: uninitialized constant #<Class:0x0055b8d9dedf68>::JsonUtils app/models/thing.rb:71:in `as_json' JsonUtils lives in app/lib/json_utils.rb . (We moved them to app/lib when lib was taken out of the autoload paths in the past.) If I run bin/rails console development , and actually, even if I run bin/rails console

Managing multiple GET parameters in Rails 5 API

[亡魂溺海] 提交于 2019-12-12 01:27:29
问题 I'm using Rails 5 API to build an app for retrieving data. I want to use multiple GET parameters to extract data. Sample GET Request Format /users?company=Samsung&position=Engineer Controller Code for single parameter:- def index client = User.where("company = ?", params[:company]) render json: client end Controller Code for multiple parameters:- def index client = User.where("company = ?", params[:company]).where("position = ?", params[:position]) render json: client end Likewise there are