ruby-on-rails-3.1

Skipping web-pages with extension pdf, zip from crawling in Anemone

点点圈 提交于 2019-12-12 17:18:53
问题 I am developing crawler using anemone gem (Ruby- 1.8.7 and Rails 3.1.1). How should I skip web-pages with extensions pdf, doc, zip, etc. from crawling/downloading. 回答1: ext = %w(flv swf png jpg gif asx zip rar tar 7z gz jar js css dtd xsd ico raw mp3 mp4 wav wmv ape aac ac3 wma aiff mpg mpeg avi mov ogg mkv mka asx asf mp2 m1v m3u f4v pdf doc xls ppt pps bin exe rss xml) Anemone.crawl(url) do |anemone| anemone.skip_links_like /\.#{ext.join('|')}$/ ... end 来源: https://stackoverflow.com

Why does f.submit not generate an id attribute in Rails 3.1?

那年仲夏 提交于 2019-12-12 16:06:30
问题 I had an issue where the following jquery script was failing in Rails 3.1 due to it not finding the element. jquery member_submit_button = $("#member_submit"); haml = form_for @member do |f| ... f.submit "Update details", :class => "member_submit_button bluebutton" In Rails 3.0 this works fine, and I tracked it down to Rails 3.1 not generating the id attribute. In rails 3.0 a tag id = "member_submit". This of course is easily fixed by adding the :id => "member_submit" parameter to the f

PDFkit rails3.1 and development env

徘徊边缘 提交于 2019-12-12 15:02:31
问题 My Rails 3.1 app is using PDFkit to render specific pages, and I'm running into (what seems like) a common problem with where trying to generate the pdf is causing the process to hang. I found this solution here on stackoverflow: rails 3 and PDFkit. Where I add a config.threadsafe! entry in my development.rb file and this works BUT it requires that for every change anywhere in the app I have to stop and restart my server to see my changes. NOT acceptable from a workflow - I'm currently

Changing attributes name in en.yml file is not working

做~自己de王妃 提交于 2019-12-12 12:27:43
问题 I changed the attributes name in en.yml file in ruby on rails project. The buttons are working fine. But the field attributes is not changing. Here is my model, class Enr::AffordableWarmth < ActiveRecord::Base self.table_name = "AffordableWarmth" self.primary_key = 'Record_No' validates_presence_of :No_Bedrooms, :No_Bedspaces, :Max_Annual_Energy_Cost validates :No_Bedrooms, uniqueness: { scope: :No_Bedspaces, message: "already exists!" } validates_numericality_of :No_Bedrooms, :No_Bedspaces,

Heroku, ZenTest and RubyGems

旧时模样 提交于 2019-12-12 11:32:35
问题 This question is a bit like this one but its solutions don't work for me. Using RVM, just upgraded to Rails 3.1 rc6. All working surprisingly smoothly except when I attempt to deploy to a new heroku Cedar staging stack I get an error: -----> Heroku receiving push -----> Ruby/Rails app detected -----> Installing dependencies using Bundler version 1.1.pre.8 Running: bundle install --without development:test --path vendor/bundle --deployment Fetching dependency information from the API at http:/

Get rails view helper methods inside coffeescript

落花浮王杯 提交于 2019-12-12 11:22:07
问题 I have a view helper, let say (for simplicity's sake) def call_alert return "alert 'this should appear'" end Then I have a coffeescript file some_test_page.js.coffee which renders for an action which is called via ajax. Inside this some_test_page.js.coffee I have: <%= call_alert %> When I do an ajax call to /some_test_page , I usually would expect to get a response with the compiled javascript from the coffeescript file and an alert would occur. However, it seems the view helper I tried to

Mongoid has_and_belongs_to_many associations

守給你的承諾、 提交于 2019-12-12 11:03:46
问题 I trying to get mongoid to save associations, but I can only get one side to work. If I have the following test. test "should add a user as a follower when a user follows the group" do @cali_group.followers = [] @user1.followed_groups << @cali_group assert_equal 1, @user1.followed_groups.count assert_equal 1, @cali_group.followers.count end Which is failing, because @cali_group.followers is []. I've been working with this for awhile, tried @cali_group.reload . But it looks like the only way

Trouble on migrating in production mode

孤街醉人 提交于 2019-12-12 10:23:31
问题 I am using Ruby on Rails 3.1.0 and the Capistrano gem and I created a migration file in order to change database table column names. When in my local machine I run the rake db:migrate command (in development mode) it works, but I would like to make effective these changes on the remote server in production mode. My problem is : if I run the Capistrano command cap deploy:migrate I get the following error message in the production log file on the remote server : * executing "cd /<my_application

Rails 3.1 Use an image without fingerprint hash

懵懂的女人 提交于 2019-12-12 10:03:08
问题 I have solved a few of my asset pipeline woes, but one of them remains. I have a couple of image_tags, and I want them to refer to the non-fingerprinted/hashed/digested version. Is there a way to force an image_tag (but only one or two, not application-wide) to use the non-digested version of the image? 回答1: Take a look at fingerprintless, that should do it. 回答2: Use :digest => false as an option to asset_path within image_tag <%= image_tag(asset_path("filename.png", :digest => false)) %> 来源: