Rails

error in your Gemfile, and Bundler cannot continue

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I just setup my mac for development and used this exact gemfile previously and it worked fine. I am not sure what I am doing wrong. Victorias-MacBook-Pro:sample_app Victoria$ bundle --without production /Users/Victoria/Sites/sample_app/Gemfile:38:in `evaluate': compile error /Users/Victoria/Sites/sample_app/Gemfile:28: syntax error, unexpected ':', expecting kEND gem 'cucumber-rails', '1.2.1', require: false ^ (SyntaxError) /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/definition.rb:18:in `build' /Library/Ruby/Gems/1.8/gems/bundler-1

Ruby on Rails: Mass-Assignment on iteration in loop?

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting mass-assignment error. Can't mass-assign protected attributes: 1, 2, 3, 4, 5, 6, 7 These numbers represent the iteration in this loop: <% (1..7).each do |i| %> <%= select_tag "hour[#{i}][day]", options_for_select(days_hours) %> <% end %> This is in my model: attr_accessible :day, :open_time, :close_time I'm trying to create an array like this: "hour"=>{ "1"=>{"day"=>"Sunday","open_time"=>"6","close_time"=>"6"}, "2"=>{"day"=>"Sunday","open_time"=>"6","close_time"=>"6"}, "3"=>{"day"=>"Sunday","open_time"=>"6","close_time"=>"6"} }

Verifying Googlebot in Rails

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am looking to implement First Click Free in my rails application. Google has this information on how to verify a if a googlebot is viewing your site here . I have been searching to see if there is anything existing for Rails to do this but I have been unable to find anything. So firstly, does anyone know of anything? If not, could anyone point me in the right direction of how to go about implementing what they have suggested in that page about how to verify? Also, in that solution, it has to do a lookup every time to try and detect google,

translate database fields with rails

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know about the built-in I18n in Rails, but how can I select a database field per locale? My model structure is something like this: title #default (englisch) title_de #(german) title_it #(italian) In my template I want to be able to write only <%= @model.title %> and should get the value in the right language. Is there a plugin or a solution to use different fields per different locale settings with a structure like mine? 回答1: Although your db architecture (different locales hardcoded as table columns) seems wrong to me, I think you can

Rails 3 Render =&gt; New with Parameter

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'v read: Rails: Pass parameters with render :action? ,but I'm still having problems. My URL for the new page is: http://localhost:3000/submit?category_id=2 . Submitting the form the first time works without any problems, but if the creation fails and the controller renders a new page I get an error can't find category without id because the parameter is not being passed. Here's a short version of the new.html.erb and new/create controllers def new ... @category = params [: category_id ] @title = "Submit a review" end def create ..

rails + ActiveRecord: caching all registers of a model

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've got a tiny model (let's call it "Node") that represents a tree-like structure. Each node contains only a name and a reference to its father: class Node < ActiveRecord :: Base validates_presence_of : name , : parent_id end The table isn't very big - less than 100 elements. It's updated rarely - in the last 4 months 20 new elements were added, in one occasion, by the site admin. Yet it is used quite a lot on my application. Given its tree-like structure, on some occasions a request triggers more than 30 database hits (including

How can can.js add a record to a Rails server?

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am using Can.js to add a record to a Ruby on Rails server: var Todo = can . Model ({ findAll : 'GET /todos' , findOne : 'GET /todos/{id}' , create : 'POST /todos' , update : 'PUT /todos/{id}' , destroy : 'DELETE /todos/{id}' }, {}); Todo . prototype . description = function () { return this . name + " and " + this . complete ; }; Todo . findAll ({}, function ( todos ) { todos . each ( function ( todo ) { console . log ( todo . name , todo . complete ); console . log ( todo . description ()); }); }); var todo = new Todo ({ name :

Invalid gemspec (Ruby on Rails)

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have successfully installed ruby on rails on Linux raspberrypi 3.10.25+. Ruby version is ruby 1.9.3p194. I imported a ruby on rails based project from github ( https://github.com/iobridge/thingspeak ). Using the command line I went into project's directory and ran "bundle install" and got the following error. Please note that not even a single bundle was installed. Installing rake 10.3 . 1 Invalid gemspec in [ /tmp/ bundler20140528 - 7444 - ym92r7 / ZenTest - 4.9 . 5 / specifications / ZenTest - 4.9 . 5.gemspec ]: Illformed

Rails authlogic password hashing algorithm using ruby only

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Does anyone know how I'd run plain text passwords through the authlogic hasing algorithm without using rails? It looks like the default for authlogic is sha512. I have a database of plain text passwords (yes, I know... bad) and need to import them into a new DB that uses the authlogic setup. This ruby script is outside of rails so I don't want to use the rails based authlogic commands. I have require 'authlogic' in the ruby script I'm new to ruby modules but was trying to call the password method like: Authlogic::ActsAsAuthentic:

rails best practice for a multistep form?

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to create a mutlistep form in Rails 3. I've watched the railscasts episode on it, but I did not feel like he was using the best practice when creating the form. I felt like it was a sloppy way to accomplish the task. What is the best way to create a multistep form using the best practices in rails? 回答1: Your question is a little hard to answer without more information, and a true answer would be a detailed tutorial (like a Railscast) rather than a SO answer, but here's some thoughts to get you on your way. There are two