ruby-on-rails-3.1

After upgrading to Rails 3.1.1: “undefined method `javascript_expansions'” error

风格不统一 提交于 2019-12-02 15:03:48
问题 Ive upgraded rails from 3.0.10 to 3.1.1 and now Im getting the following Error: undefined method 'javascript_expansions' for ActionView::Helpers::AssetTagHelper:Module but not on every page, just some pages are involved. I googled it already but I didnt find anything! Im running ruby 1.9.2 by the way... Also my asset pipeline doesnt seem to work. Its not loading the application.css and application.js file even its in the assets subfolders. Im getting a routing error each time I try to fetch

Reflecting Heroku push version within the app

本小妞迷上赌 提交于 2019-12-02 14:55:20
Every time I push my app to heroku I see the line -----> Launching... done, v43 Is there a way to make that version number apear within the app so other people can see that number? Why would you want to depend on running a command after every push? The accepted answer is worse than setting the config yourself. Instead add to your Gemfile: gem 'heroku-api' Add your App name and API key to the Heroku config: $ heroku config:add HEROKU_APP_NAME=myapp HEROKU_API_KEY=bp6ef3a9... Then put something like this in config/initializers/heroku.rb : unless (app_name = ENV["HEROKU_APP_NAME"]).nil? require

Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

社会主义新天地 提交于 2019-12-02 14:27:12
My website has been broken since Dreamhost upgraded their servers a couple of weeks ago. I have been tearing my hair out trying to get it fixed and made some progress but am stuck on what is hopefully the final issue. I'm using Rails 3.1.1 on Ruby 1.8.7 and get presented with a 'Ruby (Rack) application could not be started error' from PhusionPassenger. It states that it 'Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)'. Searching for this on Dreamhost's wiki has suggested a solution to install

Method gives ActiveRecord::Relation error?

瘦欲@ 提交于 2019-12-02 12:40:30
I have 3 models called Price, UnitPrice and Purchase. The Price and UnitPrice models have an attribute called amount that I'm trying to scope to and get the total sum of both combined. I created two scopes, one for the total sum of both models. The other scope is to get the date attribute of both model's date fields. I'm trying to do this: <%= number_to_currency(current_user.purchases.today.total) But get the error: NoMethodError in pages#home undefined method `today' for #<ActiveRecord::Relation:0x77f94c0> My Code: class Purchase < ActiveRecord::Base belongs_to :user belongs_to :price belongs

How do you quote strings in Postgres

戏子无情 提交于 2019-12-02 11:59:55
In Rails I use MySQL and have SnCl.all(:conditions => "col3=\"xx\"") but it does not work with my Postgres DB in Heroku As mentioned in the comments, most databases uses single quotes for string literals and double quotes for identifiers. MySQL is rather lax and will also accept double quotes for string literals but PostgreSQL is (thankfully) quite strict. So you want to use single quotes: SnCl.all(:conditions => "col3 = 'xx'") or using where : SnCl.where("col3 = 'xx'") or with sensible use of the database driver's quoting facilities: SnCl.where("col3 = #{SnCol.connection.quote('xx')}") And

After upgrading to Rails 3.1.1: “undefined method `javascript_expansions'” error

故事扮演 提交于 2019-12-02 10:47:59
Ive upgraded rails from 3.0.10 to 3.1.1 and now Im getting the following Error: undefined method 'javascript_expansions' for ActionView::Helpers::AssetTagHelper:Module but not on every page, just some pages are involved. I googled it already but I didnt find anything! Im running ruby 1.9.2 by the way... Also my asset pipeline doesnt seem to work. Its not loading the application.css and application.js file even its in the assets subfolders. Im getting a routing error each time I try to fetch any of the files. I got the exact same error, after removing tinymce and running bundle install

Micropost - Routing Error No route matches [GET] - Deleting a Micropost

北战南征 提交于 2019-12-02 08:51:49
I'm reading through Hartl's book, Ruby on Rails by Example. In chapter 11, it has you implement delete requests to allow users to delete microposts on their profile. However when I click the delete button, I receive this routing error: No route matches [GET] /microposts/303" I've found similar posts with other people who have had the same problem. But no one seems to have figured out a clear way to resolve this issue. Maybe it is just too late at night but I am stumped. I know it has something to do with the js file or jquery. Can you please help? Here are the other posts detailing the same

Rails render route path

做~自己de王妃 提交于 2019-12-02 07:54:12
问题 Im still new to Rails and have a hard time understanding how the path system works in Rails. In my routes.rb i create an alias for signup: match 'signup' => 'user#new' resource :user, :controller => 'user' The action is there and going to /signup shows the correct action. So far so good. Now, when i submit my signup form it runs the create action with POST as usual. And here is where im stuck. If the signup fails, i would like to present the user with the signup form again. One option would

How to manage rooms availability based on days or months occupation

浪子不回头ぞ 提交于 2019-12-02 07:24:43
I'm developing a Rails 3 application (with MySQL as RDMS) to manage availability/occupancy for some Rooms (it's an hotel-like app) In my case, the problem is I've to keep up in the system 2 different requirements because one room can be rented for: Some months (for example 6 monts) Some days/weeks/weekend Clearly the app has to show for each room in a given date, if it is available or not, and which user is renting; and on the other side, one user can search one room for a given date range. The date range can be some fixed date or some months range (from September to March for instance) and I

rails 3 associations error

萝らか妹 提交于 2019-12-02 07:15:35
I have a table pages and a table author. Each page belongs to one author. Created migrations for the tables and models as well. But getting this error while using it in form: NoMethodError in Pages#new Showing C:/rorapp/app/views/pages/_form.html.erb where line #1 raised: undefined method `build' for nil:NilClass Extracted source (around line #1): 1: <%= form_for(@page, @page.author.build) do |f| %> 2: <% if @page.errors.any? %> 3: <div id="error_explanation"> 4: <h2><%= pluralize(@page.errors.count, "error") %> prohibited this post from being saved:</h2> Trace of template inclusion: app/views