ruby-on-rails-3

My application.js won't work and application.css won't update in Rails

时光毁灭记忆、已成空白 提交于 2021-02-10 17:56:48
问题 I configured my application to work on Heroku, but I'm having a problem. In development mode, when I change a part of the CSS and refresh the browser, my CSS doesn't load. I checked the logs, and the application.css doesn't load. I need it to load every time in development mode. Also, my application.js stopped working and I dont know why. development.rb: # Do not compress assets config.assets.compress = false config.assets.precompile += %w( login.css ) # Expands the lines which load the

My application.js won't work and application.css won't update in Rails

て烟熏妆下的殇ゞ 提交于 2021-02-10 17:56:45
问题 I configured my application to work on Heroku, but I'm having a problem. In development mode, when I change a part of the CSS and refresh the browser, my CSS doesn't load. I checked the logs, and the application.css doesn't load. I need it to load every time in development mode. Also, my application.js stopped working and I dont know why. development.rb: # Do not compress assets config.assets.compress = false config.assets.precompile += %w( login.css ) # Expands the lines which load the

Rails Env Issue

て烟熏妆下的殇ゞ 提交于 2021-02-10 14:24:58
问题 So the other day I was trying to replicate some of the tests that were being ran by circleci and before some of the commands I called: export RAILS_ENV=test export RACK_ENV=test and now I guess the problem is that I seem to be stuck in test ? Also, I've tried executing those same commands except with each of the vars set to development, yet to no avail. Any ideas? 回答1: try 'unsetting' those env variables. export RAILS_ENV= export RACK_ENV= or try restarting the server to set them back to

ActiveRecord SQL queries not getting logged

旧巷老猫 提交于 2021-02-10 12:01:21
问题 I have been facing a weird problem for some time, wherein ActiveRecord queries are not getting logged in the terminal, or in the Rails console (using ActiveRecord::Base.logger = Logger.new(STDOUT) ). This is the exception that I get: Could not log "sql.active_record" event. NameError: undefined local variable or method `s' for # ActiveSupport::Notifications::Event:0x007f9ae02a60c0. I tried out a few things, including reinstalling Rails, but to no avail. Apart from wondering why this is

Friendly_ID Ruby on Rails

扶醉桌前 提交于 2021-02-10 07:26:52
问题 The URL still shows the id and not the title even after using slug. Code as follows index.html.erb <title>Blog!</title> <h1>List of the Posts</h1> <% @posts.each do |post| %> <%= link_to post.title,:id => post.slug%> <p><%= post.content %></p> <%= link_to "Edit",edit_post_path(post) %> | <%= link_to "Delete",post,:confirm=>"Are you sure ?",:method=>:delete %> <hr /> <% end %> <p><%= link_to "Add a New Post",new_post_path %></p> posts_controller.rb class PostsController < ApplicationController

Rails Select helper in form required True not working

本小妞迷上赌 提交于 2021-02-09 11:41:21
问题 I have a Rails 3.2.21 app in which I'm using a select helper in a form like so: <%= f.select :phys_option, options_for_select([["N/A", "n/a"], ["No", "no"], ["Yes", "yes"]], :selected => @call.phys_option), :include_blank => true, :required => true, :class => 'select' %> This works with basic functionality for selecting an option, including a blank option, etc. But what doesn't work is the :required => true or the :class => 'select' . I can submit the form even when the selection is blank and

How to use the slug from Friendly_id in a nested route?

时光毁灭记忆、已成空白 提交于 2021-02-08 05:38:15
问题 I am having a hard time making the slug from Friendly_id in a nested route when editing and creating? the routes look great for show. http://0.0.0.0:3000/test/tester2 This is the URL I am getting when i try to edit tester2 is: http://0.0.0.0:3000/2/tester2/edit What i would like to see is: http://0.0.0.0:3000/test/tester2/edit Here is my code. team.rb class Team < ActiveRecord::Base extend FriendlyId friendly_id :name, use: :slugged has_many :videos ... end video.rb class Video < ActiveRecord

Label references for associations

两盒软妹~` 提交于 2021-02-07 18:11:11
问题 Rails provides label references for associations in fixtures like this: ### in pirates.yml reginald: name: Reginald the Pirate monkey: george ### in monkeys.yml george: name: George the Monkey pirate: reginald This works great for not-namedspaced models, but I'm using namespaces, and so Rails gets confused, and want to insert the labels instead of the label references. Any workaround or fix known? 回答1: Fixtures.identify seems to be the only solution, not really beautiful but better than ids.

Label references for associations

北城余情 提交于 2021-02-07 18:06:40
问题 Rails provides label references for associations in fixtures like this: ### in pirates.yml reginald: name: Reginald the Pirate monkey: george ### in monkeys.yml george: name: George the Monkey pirate: reginald This works great for not-namedspaced models, but I'm using namespaces, and so Rails gets confused, and want to insert the labels instead of the label references. Any workaround or fix known? 回答1: Fixtures.identify seems to be the only solution, not really beautiful but better than ids.

Set content type in S3 when attaching via Paperclip 4?

旧街凉风 提交于 2021-02-07 11:59:15
问题 I'm trying to attach CSV files to a Rails3 model using paperclip 4.1.1, but I'm having trouble getting the content-type as reported by S3 to be text/csv (instead I am getting text/plain ). When I subsequently download the file from S3, the extension is getting changed to match the content-type instead of preserving the original extension (so test.csv is downloaded as test.txt). From what I can see, when you upload a file, the FileAdapter will cache the content-type on creation with whatever