ruby-on-rails-3

Using rubyzip error - no such file to load — zip/zip

流过昼夜 提交于 2019-12-28 06:27:27
问题 I know there is another thread on this subject but I still face this problem even after using all solutions. Is there any other way to generate zip files? Can i use Ubuntu system commands? I did gem install rubyzip I have require 'rubygems' require 'zip/zip' in my controller But i still get the same error - no such file to load -- zip/zip I tried with both ruby 1.8.7 and ruby 1.9.2 with rails 3.0.5 on Ubuntu Could you please help me? Thanks. 回答1: I fixed this problem by specifying gem version

Rails 2 to Rails 3 : using link_to instead of link_to_remote (including remote and update)

99封情书 提交于 2019-12-28 06:23:45
问题 A quick and easy answer I'm sure. I'm upgrading a Rails project from version 2 to version 3 and replacing a load of the link_to_remote with link_to's as per the Rails 3 update. Even something as simple as : <%= link_to "Check Time", {:action=>:get_time}, :remote=>true, :update=>'current_time' %> <div id='current_time'></div> doesn't seem to work. The request (using get method) is going through ok and the rendered html is : <a href="/monitoring/get_time" data-remote="true" update="current_time

Ruby on Rails Rake assets:precompile error

笑着哭i 提交于 2019-12-28 05:59:56
问题 I'm new in Rails development and this is my first deployment to Heroku. When I execute my application (after the deployment) there is an error: 2011-09-18T21:05:54+00:00 app[web.1]: Completed 500 Internal Server Error in 10ms 2011-09-18T21:05:54+00:00 app[web.1]: 2011-09-18T21:05:54+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled): I googled this and found that I have to precompile my assets, but when trying to do this I found an other error: $ bundle exec

Ruby on Rails Rake assets:precompile error

此生再无相见时 提交于 2019-12-28 05:59:14
问题 I'm new in Rails development and this is my first deployment to Heroku. When I execute my application (after the deployment) there is an error: 2011-09-18T21:05:54+00:00 app[web.1]: Completed 500 Internal Server Error in 10ms 2011-09-18T21:05:54+00:00 app[web.1]: 2011-09-18T21:05:54+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled): I googled this and found that I have to precompile my assets, but when trying to do this I found an other error: $ bundle exec

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT)

时间秒杀一切 提交于 2019-12-28 05:52:06
问题 I am using Ruby 1.9.2, Rails 3.0.4/3.0.5 and Phusion Passenger 3.0.3/3.0.4. My templates are written in HAML and I am using the MySQL2 gem. I have a controller action that when passed a parameter that has a special character, like an umlaut, gives me the following error: ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT) The error points to the first line of my HAML template, which has the following code on it: <!DOCTYPE html> My understanding is that this is

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT)

安稳与你 提交于 2019-12-28 05:52:03
问题 I am using Ruby 1.9.2, Rails 3.0.4/3.0.5 and Phusion Passenger 3.0.3/3.0.4. My templates are written in HAML and I am using the MySQL2 gem. I have a controller action that when passed a parameter that has a special character, like an umlaut, gives me the following error: ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT) The error points to the first line of my HAML template, which has the following code on it: <!DOCTYPE html> My understanding is that this is

Devise and Strong Parameters

℡╲_俬逩灬. 提交于 2019-12-28 05:35:38
问题 I would like to know how to integrate both of this gems(devise + Strong Parameters), since strong params will likely be added to the rails core in 4.0 any help is welcome thanks 回答1: Update for devise 4.x class ApplicationController < ActionController::Base before_filter :configure_permitted_parameters, if: :devise_controller? protected def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_up, keys: [:username]) devise_parameter_sanitizer.permit(:sign_in, keys: [:username

:as in rails routes.rb

拟墨画扇 提交于 2019-12-28 03:32:21
问题 In config/routes.rb , I tried both: root :to => 'things#index', :as => 'things' and root :to => 'things#index' When I hit http://localhost:3000/ , both approaches work, and nothing seems to be different. What is the :as option used for? 回答1: The :as option forms a named route. Usually it's used in a non-root route. For example: match '/search' => 'search#search', :as => 'search' # SearchController#search You could then do something like: <%= link_to search_path, 'Click Here to Search!' %>

Rails: how can I get unique values from column

99封情书 提交于 2019-12-28 03:29:06
问题 How can I get unique values from column in the table? For example, I have this Products table: ID NAME CATEGORY 1 name1 1st_cat 2 name2 2nd_cat 3 name3 1st_cat Here I want to get only 2 values - 1st_cat and 2nd_cat: <%Products.each do |p|%> <%=p.category%> <%end%> 回答1: Two more ways: Product.select(:category).map(&:category).uniq Product.uniq.pluck(:category) For Rails >= 5.1 use: Product.distinct.pluck(:category) 回答2: I think you can do this: <% Products.select("DISTINCT(CATEGORY)").each do

How to integrate a Wrap Bootstrap theme into an Rails application?

我们两清 提交于 2019-12-28 03:20:47
问题 I have bought a twitter bootstrap theme from wrapbootstrap. I already have a functional rails application. Now, I want to design my application by integrating the bootstrap theme into my application. I am new to this and I have no idea how to do it. After doing a lot of research on this, I found only a very few discussion regarding this issue. As for example I found this post: Implementing WrapBootstrap theme into Rails App But, I am not totally sure how the assets from the theme will be