ruby-on-rails-3

Deploy 2 Sites on same Apache server

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 03:14:12
问题 I need to deploy my Rails app to a server that is already serving a PHP site at its root. I can't touch the existing site, and I have to deploy my app at a sub-url or sub-domain, ie xx.xx.xx.xx/rails or rails.xx.xx.xx.xx . The Apache config I normally use to deploy my app: <VirtualHost *:80> ServerName localhost DocumentRoot "C:/RubyStack-3.2.5-0/projects/app_name/public" <Directory "C:/RubyStack-3.2.5-0/projects/app_name/public"> Allow from all Options -MultiViews </Directory> RewriteEngine

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 {

Grouping via an element in hash [closed]

好久不见. 提交于 2019-12-23 03:12:47
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . Suppose I have this array x=[{:shipping_id=>2, :fsn=>"ab", :price=>300, :quantity=>1}, {:shipping_id=>3, :fsn=>"abc",:price=>500, :quantity=>2}, {

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 {

Running a 1 time task to enter values into database in Ruby

本秂侑毒 提交于 2019-12-23 03:06:59
问题 I have now added a new column to my table in database. I want to add some values to some rows in this new column. I know the logic and all. But actually I dont know the way to add this, or write a 1 time task to do this in ruby on rails. Can any one help me. I just need some idea. 回答1: You can create a rake task for this, and run it once. Create a file lib/tasks/my_namespace.rake namespace :my_namespace do desc "My Task description" task :my_task => :environment do # Code to make db change

SSLCaertBadFile error heroku curb

女生的网名这么多〃 提交于 2019-12-23 02:57:27
问题 I have a rake task that pulls and parses JSON data over an SSL connection from an external API. I use a gem that wraps this external API and have no problems running locally, but the task fails when run on heroku with #<Curl::Err::SSLCaertBadFile: Curl::Err::SSLCaertBadFile> I installed the piggyback SSL add-on, hoping it might fix it, but no dice. Any ideas? UPDATE I managed to fix it by disabling ssl verification on the curl request previously set by the following two fields: request.ssl

How to add a method to the versions model of Paper_trail?

你。 提交于 2019-12-23 02:49:18
问题 I want to create the following method for paper_trail versions: def user User.find self.whodunnit.to_i end So that I can access a version's user naturally in my app as if it has a belongs_to relation. Where should I put this function (folder and file name) in order to override / add it to paper_trail's version model? 回答1: You could put this in an initializer (e.g., config/initializers/paper_trail.rb ) that opens the PaperTrail::Version class: module PaperTrail class Version < ActiveRecord:

Cancan + Devise rescue_from not catching exception

左心房为你撑大大i 提交于 2019-12-23 02:44:06
问题 I am implementing Devise and Cancan for user authentication and permissions. Everything works great so far except I am not able to redirect users to the login page when they are not allowed to access a specific feature. My test is: feature 'A signed in user' do before(:each) do user = FactoryGirl.create(:user) visit "/login" fill_in "user_email", :with => user.email fill_in "user_password", :with => "ilovebananas" click_button "Sign in" end scenario 'should not have access to admin dashboard'

How to create a RabbitMQ consumer on a Ruby on Rails web app?

浪子不回头ぞ 提交于 2019-12-23 02:42:26
问题 So I am building a web app that uses a Ruby on Rails frontend and a Java backend. So basically when a user logs into the website I want a list of all the transactional data history for that user to be displayed on the screen. The way I need to do this(for various reasons that I wont go in to) is to have code on the Ruby layer send a message(using RabbitMQ, packaged as a JSON object) to a queue and this message will be taken from the queue by code in the Java layer. The Java layer then needs

render_views returning NoMethodError

大憨熊 提交于 2019-12-23 02:39:27
问题 I'm currently going through the Ruby on Rails Tutorial by Michael Hartl, and in Section 3.2.2 of the tutorial, he talks about using RSpec to test for the titles of the page. My tests (which I wrote myself, following his tutorial) kept failing the title tests (it can find the tag, but the title is always a blank string), and some searching on Google told me I needed to include the function render_views to pass the tests. My problem is that no matter what I try, RSpec returns a NoMethodError