ruby-on-rails-3.1

Can't push to existing live heroku app on Cedar Stack

六月ゝ 毕业季﹏ 提交于 2019-12-13 07:12:27
问题 I successfully pushed a live app to heroku on cedar stack at livebytransit.com a few weeks ago, and I have successfully pushed code changes until recently. I have not been able to push code changes after creating a staging app from the same working directory...see afternoon-cloud-6227.herokuapp.com. My thought was to push changes first to afternoon-cloud, then if all looked good, push to the main site. As it stands right now, I can't push changes to either app. Here is some code that shows

Alllow for “bad” urls in in Rails

流过昼夜 提交于 2019-12-13 06:05:28
问题 I have a simple script which checks for bad url's: def self.check_prod_links require 'net/http' results = [] Product.find_each(:conditions =>{:published => 1}) do |product| url = product.url id = product.id uri = URI(url) begin response = Net::HTTP.get_response(uri) rescue begin http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) rescue begin response = Net:

Listing objects under the date they were created

不羁的心 提交于 2019-12-13 05:59:53
问题 Sorry for the amateur question but I am still quite new to rails. I currently have an app that creates jobs and I would like to display the jobs beneath the date they were created in the same way they do on Dribble At the moment to display the jobs I have te following: <% @jobs.each do |job| %> <div class="job-wrapper"><%= link_to user_job_path(job.user_id ,job) do %> <div class="job"> <div class="job-desc"><strong><%= job.company %></strong> are looking for a <strong><%= job.job_title %><

rails 3 how do i submit a remote form with jquery and avoid callbacks

允我心安 提交于 2019-12-13 05:57:17
问题 I have a remote => true form and would like to submit it AND avoid a submit method. Usually i would do form$.get(0).submit() form$.submit(function(){..avoid going here..}) but this sends the form as html instead of js. Any way to do this and get js in response? Thanks! 回答1: Use this code in your controller respond_to do |page| page.js {} end and add a file in your view with controller's function name ending with .js extension. 回答2: man that i was a pain to find. the answer is replace $(form)

How to update production database schema safely in rails 3.1.3?

浪子不回头ぞ 提交于 2019-12-13 05:32:45
问题 We need constantly update our database schema in production for rails 3.1.3 app. The first db schema was created with the following rails command: $rake RAILS_ENV=production db:schema:load Question is: can we still use the command above to update db schema in production while safely retaining all current data? Thanks so much. 回答1: I never used rake db:schema:load in production, but according to this answer to another question here on SO, I don't think you want to do that . On the other hand,

Can't delete record through Rails

℡╲_俬逩灬. 提交于 2019-12-13 05:32:31
问题 I have a table, say Persons and if I do person = Person.find(:first) person.delete I get NoMethodError: undefined method `to_sym' for nil:NilClass from .rvm/gems/ruby-1.9.2-p320@rails-3.1.1/gems/activesupport-3.1.1/lib/active_support/whiny_nil.rb:48:in `method_missing' from .rvm/gems/ruby-1.9.2-p320@rails-3.1.1/gems/activerecord-3.1.1/lib/active_record/base.rb:1403:in `block in expand_hash_conditions_for_aggregates' from .rvm/gems/ruby-1.9.2-p320@rails-3.1.1/gems/activerecord-3.1.1/lib/active

Ruby on Rails Tutorial by Michael Hartl. Failing Test in Chapter 9.1

ⅰ亾dé卋堺 提交于 2019-12-13 04:28:24
问题 Hi i'm working through the Hartl's Ruby on Rails Tutorial and i'm stuck with one failing test in Chapter 9.1 of. When I run spec in terminal it returns: sis-macbook-pro:sample_app Lagaspi$ bundle exec rspec spec/ ...............................F................................ Failures: 1) AuthenticationPages signin with valid information Failure/Error: it { should have_link('Users', href: users_path) } expected link "Users" to return something # ./spec/requests/authentication_pages_spec.rb

UserSession.find returns nil after changing password

荒凉一梦 提交于 2019-12-13 04:19:57
问题 I recently created a way to change the current user password, however after saving the record, my UserSession.find returns nil, I tried by writing UserSession.new({...}).save with no luck, any suggestion on how to resolve this issue? Here is my code, notice that is run through an AJAX request (this is a method under UserSessionController): def change_my_password #print "--------------RECORD: #{current_user_session.record.as_json}-------- #{current_user_session.user.as_json}" user = current

Access stylesheet_link_tag from controller

泄露秘密 提交于 2019-12-13 02:28:30
问题 Is there a was to call stylesheet_link_tag from the controller? I am creating a PDF file in memory and passing it along to an api call to another service. I am using PDFKit and it requires me to send the style sheet link to it. I am using Rails 3.1 and therefore need access to the asset pipeline through this method. Thanks for the help! 回答1: You should be able to use this to access the stylesheet from your controller: ActionController::Base.helpers.asset_path("stylesheet_i_want.css") 回答2:

Rails 3.1 asset pipeline with suburis

元气小坏坏 提交于 2019-12-13 02:12:07
问题 I'm trying to convert a Rails 3.1 app to use the asset pipeline. Currently using Rails 3.2.0.rc2. I'm setting ENV['RAILS_RELATIVE_URL_ROOT'] to the suburi in application.rb. The helpers work fine, generating the correct path (including the suburi) to the file, however Rails routes aren't serving the files off of that path. For instance, <%= stylesheet_link_tag 'screen', :media => 'screen' %> correctly generates the code <link href="/my-suburi/assets/screen.css" media="screen" rel="stylesheet"