ruby-on-rails-5

Cannot use group with has_many through in Rails 5

杀马特。学长 韩版系。学妹 提交于 2019-12-13 20:27:01
问题 I have the following associations: class Student < ApplicationRecord has_many :people_schools has_many :schools, through: :people_schools end class PeopleSchool < ApplicationRecord belongs_to :student belongs_to :school end class School < ApplicationRecord has_many :people_schools has_many :students, through: :people_schools end I am trying to get a list of students organized by their school. I have tried the following: Student.joins(:schools).all.group('schools.name') but I get the following

Can't insert MySQL query in Rails 5 (Lynda Course)

拟墨画扇 提交于 2019-12-13 18:09:32
问题 I'm taking a course on Lynda.com (Ruby on Rails 5 Essential Training) and I'm having an issue with adding a record on a table. Here's some details: The objective is to create a joint table, Many-to-Many association, so we're first trying to create a record on with of the tables we want to use on the new table. And everytime I write this line: section = Sections.create(:name => "Section One", :position => 1) It gives me this (0.2ms) BEGIN (0.3ms) ROLLBACK => #<Section id: nil, page_id: nil,

Javascript not loading on heroku

偶尔善良 提交于 2019-12-13 17:27:29
问题 I am trying to deploy an application. My javascript is loading perfectly on development but it's not loading on the production. Even I am not getting any error in production. If someone needs more information please let me know. I have already tried the below command heroku run rake assets:precompile --app my_app Also I have tried alert() function it is also not working on heroku. <script type="text/javascript"> $(function() { $(document).ready(function() { $('.flexslider').flexslider({

uninitialized constant Rails::Command::Actions::APP_PATH (NameError) when trying to start Rails engine server

为君一笑 提交于 2019-12-13 17:23:50
问题 The full error is ~/.gem/ruby/2.4.0/gems/railties-5.1.5/lib/rails/command/actions.rb:8:in `set_application_directory!': uninitialized constant Rails::Command::Actions::APP_PATH (NameError) I recently upgrade from Rails 4.x to 5.x. 回答1: You need to generate (or regenerate) "binstubs" for the dummy application. cd spec/dummy bundle exec rails app:update:bin You should now be able to start the dummy application, from the spec/dummy directory, as such: bundle exec bin/rails server The spec/dummy

Triply nested model's form in rails showing error

懵懂的女人 提交于 2019-12-13 17:19:14
问题 I am implementing triply nested form where you can see I am also showing the triply nested Task model's content and also rendering a form to add new Task. The task list is displayed correctly- which means the fet has a valid Feature model, But dont know why it is failing when rendering the new task form unexpectedly!! where it shows-> ActionController::UrlGenerationError in Projects#show No route matches {:action=>"index", :controller=>"tasks", :feature_id=>nil}, missing required keys: [

How to test or bypass Basic Auth in Rails 5 testing of controllers

谁说胖子不能爱 提交于 2019-12-13 14:12:47
问题 I would like to test controllers in Rails 5 for which Basic Authentication is activated. The way explained in the current official instruction (as of 2018-10-14) does not work for some reason. The Q&A "Testing HTTP Basic Auth in Rails 2.2+" seems too old for Rails 5 (at least for the default). Here is a simplified example to reproduce the case. I made an Article model and related resources by scaffold from a fresh install of Rails (latest stable version 5.2.1): bin/rails g scaffold Article

Link_to tag to display map modal Rails 5

吃可爱长大的小学妹 提交于 2019-12-13 13:26:49
问题 When I click on a map marker a modal pops up as such: I just implemented a search feature and am trying to get it when I click on a result a modal with all the information will pop up just like in the photo. Here is the code I am working with for that page: MapsController: class MapsController < ApplicationController def index @maps = Map.all @hash = Gmaps4rails.build_markers(@maps) do |map, marker| marker.lat map.latitude marker.lng map.longitude marker.json({:id => map.id, :number => map

ActionCable: One channel per user

妖精的绣舞 提交于 2019-12-13 12:08:27
问题 I am working on notifications for my rails app. There is User model and controller and Like model associated to User with a User has many Likes association. The idea is, if a user likes the profile of another user, owner of the profile will get a live notification. This is my app for understanding ActionCable. I studied the cable api, pub-sub was new to me. I was able to make successful communication through a single channel, and also successfully used the authorization. But, still I don't

Agile Web Development Rails 5 test failures

本小妞迷上赌 提交于 2019-12-13 09:11:39
问题 I just finished creating the Depot app from the Agile Web Development with Rails 5 textbook. For some reason, I am getting errors & failures when I run 'rails test'. Can someone explain why this is happening? My Github repository is here: https://github.com/christopheragnus/Agile_Web_Development_with_Rails_5 Christophers-MacBook-Pro-3:depot Agnus$ rails test Running via Spring preloader in process 45997 Run options: --seed 52040 # Running: ..............F Failure: LineItemsControllerTest#test

Spree Commerce: No Products Found

﹥>﹥吖頭↗ 提交于 2019-12-13 09:01:58
问题 my store ypill.com, which had run about three months, run into "no products found" today. I did not change any app code. I went to storefront and search some product where I added it, spree threw an error "no products found. Taxonomies are displaying, but "no products found" anywhere. ruby 2.3.0; rails 5.0.2 spree 3.2.1 回答1: I tried searching for keyword body I got the desired results. Try this url Please be specific about your issue and provide the keywords for which it's not working 来源: