ruby-on-rails-3.1

Sprockets generating incorrect logical_path for javascript files

放肆的年华 提交于 2020-01-05 12:16:19
问题 Sprockets seems to make an error in determining the logical_path of my javascript assets (except for application.js). It prepends "../javascripts" to the path and so my references are wrong and the application.js file won't precompile. I'm using Rails Thin server on Windows. Gemfile: source 'http://rubygems.org' gem 'rails', '3.1.3' gem 'eventmachine', '1.0.0.beta.4.1' gem 'thin' gem 'mysql' gem 'win32-open3-19' gem 'paperclip', '2.3.8' gem 'jsmin' gem 'will_paginate' gem 'jquery-rails' #

ActiveRecord::RecordNotFound in PostsController#show clicking a link

£可爱£侵袭症+ 提交于 2020-01-05 09:12:50
问题 <li><%= link_to('More Commented', posts_morecommented_path) %></li> Error ActiveRecord::RecordNotFound in PostsController#show Couldn't find Post with id=morecommented Request Parameters: {"id"=>"morecommented"} Where am I doing the mistake? postscontroller#show action def show @post = Post.find(params[:id]) ... end morecommented.html.erb <% @moreCommented.each do |t| %> <%= link_to t.title, :controller => '/posts', :action => 'show', :id => t.id %><br/> <% end %> rake routes post GET /posts/

Rails 3.1 Custom Controllers and Views w/ Default

巧了我就是萌 提交于 2020-01-05 09:03:23
问题 Background: I'm building an app that lets users create their own website (e.g., mywebsite.alexlod.com) Each website owner is affiliated with me, so I'll trust them to write their own rails code Each website should have default controllers and views, except when one of these owners creates their own Here's how I envision controllers working: I'm thinking that what's in app/controllers/ will be the default, but when a file is specified in a <subdomain> top-level directory, that file will take

No route matches [GET] “/book/list”

半城伤御伤魂 提交于 2020-01-05 07:53:08
问题 I am using Rails 3.2.7. I have a controller and a action as it's shown below: class BookController < ApplicationController def list @books = Book.find(:all) end end I also created a model with the name book.rb under model and a list.rhtml inside \app\views\book folder. When I hit http://127.0.0.1:3000/book/list , I am getting this error: No route matches [GET] "/book/list"** Here's config/routes.rb : Ravi::Application.routes.draw do # The priority is based upon order of creation: # first

You are being redirected. rails 3.1

橙三吉。 提交于 2020-01-05 03:03:25
问题 I created simple scaffold, it has the destroy method with respond_to do |format| format.html { redirect_to :action => "index", :status => 302 } format.json { head :ok } end end when I click "Destroy", I see the page with words "You are being redirected." where word "redirected" is link to the posts_path. what should i do to fix this bug? 回答1: I would pull out the :status => 302' option and double check that my Destroy link has :method => 'delete' set. If the :method` isn't set on the link

Routing without the model name

∥☆過路亽.° 提交于 2020-01-04 09:12:53
问题 Using this question and railscast 63 I've got my articles routed to articles/article_permalink. I'd like them to be accessible without the model name in the url so my-domain.com/article_permalink routes directly to the article. I'd only want this to happen on the show action. Is this possible? 回答1: I think you need something like ... (in routes.rb) match '/:id' => 'articles#show', :via => 'get' (needs to be last, or towards the end of the routes as it can match requests intended for other

Rails 3.1 Asset Pipeline and Caching

我的梦境 提交于 2020-01-03 16:56:38
问题 I'm working with Rails 3.1's asset pipeline and although it seems to work flawlessly in my development environment on my localhost, I'm having huge issues with it on engine yard. Here's my basic problem. When I include images for a background in one of my scss files: a { color: #3c7f8b; font-weight: bold; padding-left: 35px; font-size: 13px; display: block; background: white url(shade.png) top right; &:hover { color: #222222; background: white url(shade2.png) top right; } &.on { color:

Rails 3.1 Asset Pipeline and Caching

时光怂恿深爱的人放手 提交于 2020-01-03 16:56:34
问题 I'm working with Rails 3.1's asset pipeline and although it seems to work flawlessly in my development environment on my localhost, I'm having huge issues with it on engine yard. Here's my basic problem. When I include images for a background in one of my scss files: a { color: #3c7f8b; font-weight: bold; padding-left: 35px; font-size: 13px; display: block; background: white url(shade.png) top right; &:hover { color: #222222; background: white url(shade2.png) top right; } &.on { color:

javascript included twice in a Rails 3.1 asset-based app

∥☆過路亽.° 提交于 2020-01-03 15:56:56
问题 Although the title of the question is very similar to a number of previous ones, my issue seems different. Briefly, the first item in the js manifest is included twice. Here's the whole of my /app/assets/javascript/application.js file in a Rails 3.1 application: //= require jquery //= require jquery-ui //= require jquery_ujs //= require autocomplete-rails //= require utilities And here's a snippet of the rendered page's source: <script src="/assets/jquery.js?body=1" type="text/javascript"><

Different views for subclasses

拟墨画扇 提交于 2020-01-02 20:18:11
问题 I'm using STI subclasses and want to direct to different views for the different subclasses. At the moment I'm routing the subclass topic to the main class article like this: resources :topics, :controller => 'articles' Is there an easy way to direct to different views? Edit The best way I've found of doing this is: <% case%> <% when @article.type == 'Topic' %> <%= render 'topic' %> <% else %> <%= render 'article' %> <% end %> 回答1: If you name your views smartly enough, you could just do