ruby-on-rails-3.2

Guard Ruby On Rails 3.2 Tutorial

落爺英雄遲暮 提交于 2019-12-23 03:32:12
问题 I'm following along with the Ruby on Rails Tutorial. Things are working pretty well, but I noticed that Guard only runs after I save some files (view or controller files), but doesn't run when I save others (routes or spec files). I've got Guard hooked up to Spork, not sure if that matters. When I looked at the console window running Guard/Spork, I noticed an error after I saved the non-running tests: Exception encountered: #<LoadError: no such file to load -- /Users/Tyler/Development

Capybara::ElementNotFound: Error

狂风中的少年 提交于 2019-12-23 03:12:56
问题 i am following railstutorial.org tutorial i am getting the following error 1) User pages signup with valid information should create a user Failure/Error: fill_in "password" , with: "foobar" Capybara::ElementNotFound: cannot fill in, no text field, text area or password field with id, name, or label 'password' found # (eval):2:in `fill_in' # ./spec/requests/user_pages_spec.rb:32:in `block (4 levels) in <top (required)>' 2) Authentication signin with invalid information Failure/Error: before {

Capybara::ElementNotFound: Error

这一生的挚爱 提交于 2019-12-23 03:12:06
问题 i am following railstutorial.org tutorial i am getting the following error 1) User pages signup with valid information should create a user Failure/Error: fill_in "password" , with: "foobar" Capybara::ElementNotFound: cannot fill in, no text field, text area or password field with id, name, or label 'password' found # (eval):2:in `fill_in' # ./spec/requests/user_pages_spec.rb:32:in `block (4 levels) in <top (required)>' 2) Authentication signin with invalid information Failure/Error: before {

Create a custom Rails Logger

拟墨画扇 提交于 2019-12-23 02:58:07
问题 Is this outdated? http://guides.rubyonrails.org/debugging_rails_applications.html I am following it step by step, And in part '2.1 What is the Logger?' It says how to create a custom logger. 1) You can specify an alternative logger in your environment.rb or any environment file: Rails.logger = Logger.new(STDOUT) Rails.logger = Log4r::Logger.new("Application Log") I put this code in my environment.rb file and I get this: uninitialized constant Log4r (NameError) ..then it says 'Or in the

validate presence of url in html text

大城市里の小女人 提交于 2019-12-23 01:37:09
问题 I would like detect and filter if html text sent from a form, contains url or urls. For example, i send from a form this html: RESOURCES<br></u></b><a target="_blank" rel="nofollow" href="http://stackoverflow.com/users/778094/hyperrjas">http://stackoverflow.com/users/778094/hyperrjas</a> <br><a target="_blank" rel="nofollow" href="https://github.com/hyperrjas">https://github.com/hyperrjas</a> <br><a target="_blank" rel="nofollow" href="http://www.linkedin.com/pub/juan-ardila-serrano/11/2a7/62

Google plus not able to share?

半腔热情 提交于 2019-12-23 01:19:49
问题 Currently my web site is in staging i.e., working as IP address http://example.com. I have added google share button to share web pages in g+. When I try to share a link like this http://example.com/index/ It shows error like "There was a problem saving your post. Please try again." Can I share IP address in g+. Please help. -- 回答1: In order for the share button to work, the page in question must be publicly accessible. The Google share bot needs to be able to get to your page to get the

How to protect my e-mail address from spambots

痴心易碎 提交于 2019-12-22 19:15:09
问题 I was wondering what rails offers to obfuscate e-mail addresses to protect it from crawlers, spambots and mail harvesters, gathering addresses to send spam. May be I used wrong keywords, but wasn’t really able to find a gem. I found a statistic comparing different methods to mask the mail address: http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared/ I wrote a snippet that combines the top two methods. The snipped isn’t mature yet, but I like to share it

Ruby on Rails flash messages in French

谁说我不能喝 提交于 2019-12-22 18:21:20
问题 Working on a rails app in French, however whenever i include an accent on the flash messages it breaks the site. For example format.html {redirect_to @message.annonce, notice:"Votre message a été envoyé"} format.html {redirect_to @message.annonce, notice:"Votre email n'a pas pu être envoyer à cause d'une erreur."} my config/application.rb looks like this config.i18n.default_locale = :fr config.encoding = "utf-8" How does one do about this? 回答1: You should add # encoding: UTF-8 as the first

Using crc32 tweak on has_many relations in Thinking Sphinx

北城余情 提交于 2019-12-22 18:06:44
问题 It's weird actually. I have two models that have has_many relation each other, here are my models #model city class City < ActiveRecord::Base belong_to :state end #model state class State < ActiveRecord::Base has_many :city end and I have state index ThinkingSphinx::Index.define 'state', :with => :active_record do indexes state_name, :sortable => true #here is the problem has "CRC32(cities.city_name)", :as => :city_name, :type => :integer end I want to use city_name as a filter. My code above

Devise & Custom Rails User URLs

纵然是瞬间 提交于 2019-12-22 12:26:10
问题 I am currently using Rails 3.2.5 with the latest devise gem. Currently users can access their profile page at... example.com/users/john-doe I want to remove the users portion of the url, so the url would be example.com/john-doe . Is this possible with devise? Right now in my routes file I have the following... devise_for :users, :controllers => {:omniauth_callbacks => 'omniauth_callbacks'} 回答1: Just add a route for it. You will probably want it to be the last one in the routes file. Something