ruby-on-rails-3

How to run ruby files?

放肆的年华 提交于 2020-01-21 20:22:02
问题 Example I have the file test.rb: puts "test test test" How do I run this file in the ruby console? 回答1: load 'test.rb' Do you mean Rails console? (Same thing, but the question is tagged rails.) 回答2: load("test.rb") should do the trick in irb . 回答3: On Mac you can run in three different ways from the terminal Method 1 On Terminal irb (Interactive Ruby Shell) for line by line execution then quit command to be out of irb. Method 2 As ruby is Interpreted language we can run by one command on

rails 3.2 streaming data

六月ゝ 毕业季﹏ 提交于 2020-01-21 19:15:10
问题 apparently the render :text method with proc is not any longer available in rails 3.2 in order to stream data. I followed the instruction in the folowing discussion and tried to stream data with an iterator class Streamer attr_reader :url,:uri def initialize(url) puts "there" @url = url @uri = URI.parse url end def each Net::HTTP.start(uri.host) do |http| resp = http.get(uri.path) do |str| puts str end end end end this print out the streamed data to the console, but the ultimate goal is

500 error page not showing on Heroku

不打扰是莪最后的温柔 提交于 2020-01-21 13:19:36
问题 I'm trying to get a custom 500 error page to show on Heroku, running rails 3.2.11 I've followed the steps at: https://devcenter.heroku.com/articles/error-pages The process worked fine for the maintenance page, but doesn't seem to work for the error page. I'm positive the S3 URL is correct in Heroku, and when I visit the S3 URL directly I can view the error page just fine (it is set to public). config.consider_all_requests_local is set to false in production.rb Any ideas as to why Heroku is

rails 3.1 upgrade => error

旧时模样 提交于 2020-01-21 09:05:14
问题 I just upgraded an existing rails 3 app to rails 3.1 I get this on any request: Error during failsafe response: wrong number of arguments (6 for 5) /Users/janlimpens/.rvm/gems/ruby-1.8.7-p352@rails3/gems/actionpack-3.1.0/lib/action_view/lookup_context.rb:85:in `find' /Users/janlimpens/.rvm/gems/ruby-1.8.7-p352@rails3/gems/actionpack-3.1.0/lib/action_view/lookup_context.rb:85:in `find_template' /Users/janlimpens/.rvm/gems/ruby-1.8.7-p352@rails3/gems/actionpack-3.1.0/lib/action_view/renderer

rails 3.1 upgrade => error

▼魔方 西西 提交于 2020-01-21 09:03:05
问题 I just upgraded an existing rails 3 app to rails 3.1 I get this on any request: Error during failsafe response: wrong number of arguments (6 for 5) /Users/janlimpens/.rvm/gems/ruby-1.8.7-p352@rails3/gems/actionpack-3.1.0/lib/action_view/lookup_context.rb:85:in `find' /Users/janlimpens/.rvm/gems/ruby-1.8.7-p352@rails3/gems/actionpack-3.1.0/lib/action_view/lookup_context.rb:85:in `find_template' /Users/janlimpens/.rvm/gems/ruby-1.8.7-p352@rails3/gems/actionpack-3.1.0/lib/action_view/renderer

switching from MySQL to PostgreSQL for Ruby on Rails for the sake of Heroku

喜夏-厌秋 提交于 2020-01-21 06:53:28
问题 I'm trying to push a brand new Ruby on Rails app to Heroku. Currently, it sits on MySQL. It looks like Heroku doesn't really support MySQL and so we are considering using PostgreSQL, which they DO support. How difficult should I expect this to be? What do I need to do to make this happen? Again, please note that my DB as of right now (both development & production) are completely empty. 回答1: Don't feel you have to migrate to Postgres - there are several MySQL Addon providers available on

How to generate json tree from ancestry

依然范特西╮ 提交于 2020-01-21 06:41:46
问题 I use ancestry to make a tree of goals. I would like to send the contents of that tree to the browser using json. My controller is like this: @goals = Goal.arrange respond_to do |format| format.html # index.html.erb format.xml { render :xml => @goals } format.json { render :json => @goals} end When I open the json file, I get this output: {"#<Goal:0x7f8664332088>":{"#<Goal:0x7f86643313b8>":{"#<Goal:0x7f8664331048>":{"#<Goal:0x7f8664330c10>":{}},"#<Goal:0x7f8664330e68>":{}},"#<Goal

How to stop Savon from adding prefixes to soap.body

亡梦爱人 提交于 2020-01-21 05:32:06
问题 This is how I am creating a a client: @client = Savon::Client.new do wsdl.document = my_document wsdl.endpoint = my_endpoint end and this is how I'm getting a response: @response = @client.request :the_action do soap.body = xml soap.body = {"applicationId" => my_application_id } end However, this generates the following xml: "<ins5:applicationId>XXXXXXXXXXXXXX</ins5:applicationId>" My soap service errors out because of the prefix. If I do this instead, it works: @response = @client.request

Selenium doesn't work with Cucumber/Capybara (out of the box) - MacOSX

安稳与你 提交于 2020-01-21 05:03:21
问题 I'm having trouble trying to get a cucumber example to run under selenium. I'm running Rails3 Cucumber 0.10.0 Capybara 0.4.1.2 Reading the doco on https://github.com/jnicklas/capybara, it would appear that all that I need to get an example to run under selenium is to do the following: Step 1: Prefix the scenario with @javascript @javascript Scenario: User does x ... Step 2: Configure env.rb to tell capybara which driver to use: Capybara.javascript_driver = :selenium When I run: bundle exec

Telling Bundler to exclude certain gems from a particular gem's installation

China☆狼群 提交于 2020-01-21 03:32:06
问题 Within a gemfile, is there any way to tell Bundler something like: gem 'twitter-bootstrap-rails', :exclude therubyracer I need to install twitter-bootstrap-rails but it automatically pulls therubyracer in, so bundle install fails and bootstrap isn't included in the project since this is a Windows machine. I installed execjs to no avail. I tried to list therubyracer under production, and bundle install --without production , also to no avail. "therubyracer gem on windows" is also this problem,