ruby-on-rails-3.1

therubyracer fails to build on heroku

旧街凉风 提交于 2019-12-08 03:31:12
问题 I've made a Rails 3.1 PoC application that also uses haml by adapting the examples from the railstutorial.org book and locally everything works fine. But when I try to push to heroku , therubyracer fails to build on the server (full output) : Installing therubyracer (0.8.2) with native extensions /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) My Gemfile is pretty standard

Jquery-ui doesn't work on Heroku, but on localhost yes

独自空忆成欢 提交于 2019-12-08 03:12:16
问题 I have an app and I use there the autocomplete gem. It works me great on localhost. But when I deploy this app to Heroku, the autocomplete plugin doesn't works me. No errors in Firebug, just nothing. Does anyone an idea, where could be a problem? This is how look my Gemfile : source 'http://rubygems.org' gem 'rails', '3.1.2' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' gem "rvm", "~> 1.9.2" gem 'authlogic' gem "rake", "0.8.7" gem 'json'

Huge json object to excel?

主宰稳场 提交于 2019-12-08 01:56:53
问题 I have a PHP application which has a table with more then 10000 rows and I am trying to export that into an excel sheet via my ROR application but my request is getting timed out on the server by PHP application.So I was wondering is there any elegant way to solve this problem. I come up with 2 solutions. First is doing a batch processing (need to read about as I am new with it) and the other is that my php application will send a large json object and my ruby app will read that json object

form multiple select

我是研究僧i 提交于 2019-12-08 01:36:43
问题 I am learning rails and have been struggling with this for over a day now and can not figure out how to get this to work. I want a select box in my form that can select multiple elements. I have this working with this code: <div class="field"> <%= f.label :products %><br /> <%= f.select :products, {"A"=>1, "B"=>2, "C"=>3, "D"=>4},{},:size=>5,:multiple=>true %> </div> This works fine and produces this HTML: <div class="field"> <label for="script_products">Products</label><br /> <select id=

How to write an image to filesystem in rails 3.1.1?

假如想象 提交于 2019-12-08 00:06:28
I feel like I should be really close, but I can't get this to work just quite right. I'm sending an image using filetransfer from my phonegap app to my rails app (3.1.1 ruby 1.8.7 btw). I want to write the file to the filesystem. This is the params hash: Parameters: {"file"=>#<ActionDispatch::Http::UploadedFile:0x7f1e2baa94e8 @tempfile=#<File:/tmp/RackMultipart20120607-5707-owzii5-0>, @headers="Content-Disposition: form-data; name=\"file\"; filename=\"image.jpg\"\r\nContent-Type: image/jpeg\r\n", @content_type="image/jpeg", @original_filename="image.jpg">} Basically, I can access the file

How to swap jquery for prototype in Rails 3.1

落爺英雄遲暮 提交于 2019-12-07 23:29:30
问题 I have a rails 3.1 project that was created with the default jQuery. What is the best way to convert the project to use prototype instead? 回答1: Remove the jquery gem from Gemfile add prototype-rails to it From https://github.com/rails/prototype-rails: You may want to add them to your app/assets/javascripts/application.js: //= require prototype //= require prototype_ujs //= require effects //= require dragdrop //= require controls New applications using this may also want to add config.action

Ruby on Rails: Multiple Same Input Fields in Same Form

末鹿安然 提交于 2019-12-07 20:18:06
问题 Have a page where there are multiple input fields of the same thing, Posts. Right now, when a user enters in a question for, let's say 3 fields, the only one that saves to the database is the last one. Whereas, it should save all three and give them each it's own post_id. Also; if the user doesn't enter anything in for the other fields, it should not save in the database either. <%= form_for(@post) do |f| %> <%= f.text_field :content %> <%= f.text_field :content %> <%= f.text_field :content %

rails 3.1, devise gem, :timeoutable is not working, why?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 19:28:13
问题 I am trying to use the auto signout feature, here is my model: class Student < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :timeoutable def timeout 3.seconds end end here is the routes.rb: devise_for :students do get '/students/sign_out' => 'students/sessions#destroy' end I sign-in, then I wait 5 seconds, at this time, student session should be expired, but, if vavigating to any other protected page is not

Rails Routing Error for nested form_for

余生长醉 提交于 2019-12-07 18:55:03
问题 I now this has been asked a thousand times but that doesn't help me heh :) I've been at this an hour. My form: = form_for @comment, :url_for => { :action => "create", :controller => "comments"}, :method => :post my rake routes: POST /t/:trunk_id/r/:root_id/comments(.:format) {:action=>"create", :controller=>"comments"} trunk_root_comment GET /t/:trunk_id/r/:root_id/comments/:id(.:format) {:action=>"show", :controller=>"comments"} The error: undefined method `comments_path' for #<#<Class

How do I apply an 'active' class to my navigation based on the current_page in a DRY way? - Rails 3

旧街凉风 提交于 2019-12-07 16:38:05
问题 So in my application.html.erb I have my navigational structure that looks something like this: <div id="navigation"> <ul class="pills"> <% if current_page?(:controller => 'welcome', :action => 'index') %> <li><%= link_to "Profile", vanity_path(:vname => current_user.username) %></li> <li><%= link_to "Settings", settings_path %></li> <li><%= link_to "Sign Out", signout_path %></li> <% elsif !current_page?(:controller => 'welcome', :action => 'index') %> <li><%= link_to "Home", root_path %></li