ruby-on-rails-3.1

Rack::Deflater apparently gzip page but it appears as gibberish in browser

大憨熊 提交于 2019-12-24 08:51:16
问题 I've deployed a rails 3.1 app on the new cedar stack on heroku. The new stack doesn't automatically provide gzipping so I've added use Rack::Deflater in my config.ru Testing it through curl with the following command: curl -i -H 'Accept-Encoding: gzip,deflate' http://carbuzz-production.herokuapp.com Returns an header with content encoding gzip and a body that seems compressed. Opening the page in firefox or chrome shows the body untranslated (lots of gibberish). Any idea how to solve this?

Rails controller path not found

那年仲夏 提交于 2019-12-24 08:20:55
问题 My form tag in my view: <%= form_tag view_all_rater_path, :method => 'get' do %> <p> <%= text_field_tag :search, params[:search], :placeholder => 'Search by Set # or date' %></br> <%= submit_tag "Search", :class => "btn btn-link", :name => nil %> </p> <% end %> My controller action: def view_all if params[:search] @ratings = RatingSet.find(:all, :conditions => ['id = ? or rating_date like ?', "%#{params[:search]}%"]) else @ratings = RatingSet.all end end My routes: resources :rater, :only =>

failed to allocate memory on the console and internal server error on the browser

不问归期 提交于 2019-12-24 07:09:42
问题 I have this error while loading the data from files in to database. Please help me out in getting this right. here is the method : clusters.each do |cluster| cluster_path = cluster.path root = current_root + cluster.name+'/' Log.info "<br/> --------- Starting data popuation for #{cluster_path} ---------------" population_time[:bp_data] = populate_bp_data(root+fileName[:bp_data], cluster_path, @dataset.id) population_time[:m_lint] = populate_m_lint(root+fileName[:m_lint], cluster_path,

Using Closure_tree gem instead of Awesome nested set

给你一囗甜甜゛ 提交于 2019-12-24 06:35:30
问题 Hi I followed the link to set up closure_tag gem. When i tried to use closure_tree syntax in the following way (newStructure.find_or_create_by_path(parent) instead of newStructure.move_to_child_of(parent)) ... got the following error : "Can't mass-assign protected attributes: ancestor, descendant, generations" is this the correct way of using newStructure.find_or_create_by_path(parent) ? def self.import(path) newStructure = FileOrFolder.find(:first, :conditions=>["fullpath = ?", path]) if

Rails 3.1, Ruby 1.9.2-p180 and UTF-8 issues

删除回忆录丶 提交于 2019-12-24 04:54:16
问题 I'm having some trouble with UTF-8 characters. Here's db/seeds.rb User.create(username: 'eml', first_name: '****', last_name: '****äck', email: 'somemail@example.com', password: 'asdasd') My terminal (OSX 10.5.8) is set to use UTF-8, Rails (according to application.rb) is set to use utf-8. Here's the error: $ rake db:seed rake aborted! /Projects/***/db/seeds.rb:8: invalid multibyte char (US-ASCII) /Projects/***/db/seeds.rb:8: invalid multibyte char (US-ASCII) /Projects/***/db/seeds.rb:8:

Ruby if condition not working properly in javascript file

不想你离开。 提交于 2019-12-24 02:58:36
问题 Controller: def AjaxView @vars= Var.find(:all,:conditions => { :varName=> "one" },:select=>(params[:col])) @col = params[:col] respond_to do |format| format.js { render :layout=>false } end end AjaxView.js.erb if('<%= @col %>' == 'colName'){ $("#3").text("<%= escape_javascript(render(:partial => "var")) %>"); } else if('<%= @col %>' == 'colName2'){ $("#2").text("<%= escape_javascript(render(:partial => "var1")) %>"); } View Partial: _var.html.erb <%= @vars[0].colName %> _var1.html.erb <%=

How to give ActiveAdmin its own application layout? — Rails newbie

若如初见. 提交于 2019-12-24 01:01:59
问题 It's probably a dead simple question. Right now it uses the default application layout file. How can I create one just for AdminAdmin in order keep it separate from the one used on the main site? 回答1: Read layouts and rendering guide, there is paragraph about :layout option. You can specify layout, or set it to false, to render without layout at all. render :layout => 'special_layout' render :layout => false 回答2: If my memory does not fail me again !! ;-) this rails cast talk about this. But

Creating a Blank Rails 3.1 Templating Handler

孤街浪徒 提交于 2019-12-24 01:01:42
问题 What I want to do is make it just output the view itself, and ignore what Rails would normally think is embedded Ruby within the HTML. For example: <div class="current"> <div class="question"> <h3 id="homework_name"><%= homework.name %><h3 id="due">Due <%= homework.due %></h3></h3> <h2 class="title">The Question:</h2> <p id="question_contents"class="contents"><%= current_question.contents</p> </div> <div class="answer"> <h2 class="title">Your Answer:</h2> <textarea class="contents" id=

Why do I get an error installing bson_ext?

醉酒当歌 提交于 2019-12-24 00:57:05
问题 When I execute the following command in the Rails project folder: gem install bson_ext I get the this error: #result Building native extensions. This could take a while... ERROR: Error installing bson_ext: ERROR: Failed to build gem native extension. /home/absolute/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb checking for asprintf()... yes checking for ruby/st.h... yes checking for ruby/regex.h... yes checking for ruby/encoding.h... yes creating Makefile make compiling bson_buffer.c

Rails 3: How to intercept any http request

坚强是说给别人听的谎言 提交于 2019-12-24 00:23:55
问题 Lets say I have an image at app/assets/images/privateimages/myrestrictedimage1.jpg If I try to go directly to the image via url say with something like http://localhost:5555/assets/privateimages/myrestrictedimage1.jpg I am able to view the image. I would like to have a way to inspect any http request to decide if the user is allowed access to it. I know I can use before_filter in controllers to do some preprocessing before continuing onto any of the controller actions but I dont think this