ruby-on-rails-3.1

I need precompile assets every time I've made any change to see difference in browser

余生长醉 提交于 2019-12-04 08:42:50
问题 Like as I mentioned in title - I have to precompile assets every time I've made any change to see how it looks like - I've tried config.assets.compile = true , without success. I've also tried RAILS_ENV = 'development' but with same effect. Please help me because it is really annoying. My system is running on: Xubuntu Rails -v: 3.1.1 Ruby -v: 1.9.2p290 I also tried: config.action_controller.perform_caching = true 回答1: One cause of this could be that you ran rake assets:precompile once. The

Heroku is trying to install sqlite3 gem even it not being in the Gemfile

空扰寡人 提交于 2019-12-04 08:21:52
问题 I'm trying to deploy a Rails 3.1 application for the first time on Heroku. I set it to the Cedar stack, removed the sqlite3 gem but when I push the code to Heroku I get this error: -----> Installing dependencies using Bundler version 1.1.rc Running: bundle install --without development:test --path vendor/bundle --deployment Fetching gem metadata from http://rubygems.org/....... (...) Installing rails (3.1.0) Installing sqlite3 (1.3.4) with native extensions Unfortunately, a fatal error has

How do I install Ruby 1.9.3 on Ubuntu without RVM?

送分小仙女□ 提交于 2019-12-04 08:06:52
问题 I want to install ruby 1.9.3 on Ubuntu without rvm I run sudo apt-get install ruby It's taking ruby 1.8 and ruby 1.9.1. And if I do sudo apt-get install ruby 1.9.3 -p XXXX I am still not able to install ruby. How can I install ruby on Ubuntu? 回答1: On Ubuntu 12.04 LTS, I got it to work with the following: sudo apt-get install ruby 1.9.3 cd /etc/alternatives sudo ln -sf /usr/bin/ruby1.9.3 ruby 回答2: Use the brightbox packages for 1.9.3. You will have to add their repo though but to keep it short

How to take screenshot of a website with Rails 3.1? — without using a service

泪湿孤枕 提交于 2019-12-04 07:50:07
问题 Almost every answer I've found references using some existing service. Is there a way to do this using Rails 3.1 programmatically? This was dead easy to do with PHP (there are prebuilt libraries in PHP that do this). What I'm looking to do, given a URL, is: Take a screenshot of the website Crop it (only take the top left most 100x100 pixels PS. Here is my environment: Rails 3.1 , Ruby 1.9.2 Note: The solution would probably need to follow any redirections on the URL as well. Updates: I've

Rails 3.1 Mountable Engines : How to use/template it inside another application?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 07:29:45
Let's say I created a mountable engine called 'Soho' that has a controller for 'Users'. I can go to /users/1 to see my user with ID 1. Inside 'Soho', I have a application.html.erb for layout. Now let's assume I want to "blend" my engine 'Soho' in an application called 'Soho_test', and I mount my engine at "/". So, in my host application 'Soho_test', I can also go at /users/1 to see my user with ID 1. This is working. My question is : how can I do in my host application 'Soho_test' to apply the 'Soho_test' application.html.erb to the /users/1 (user profile page) instead of the one in the 'Soho'

Why does a single record lookup return an array? (Rails beginner)

 ̄綄美尐妖づ 提交于 2019-12-04 07:24:42
I have a where operation on a model that returns a single object. But I can't seem to use it in object notation (it appears to return an array with the object at [0]). store = Store.where("some_id = ?", some_id) puts store.name # doesn't work puts store # shows array with the object at [0] Because sometimes you don't know how many objects a query should return, so for consistency you always get an array. To get a single object use store = Store.where("some_id = ?", some_id).first If you are looking for the primary ID of the model, you can also use store = Store.find(some_id) which will raise a

Devise render sign => up/in form partials elsewhere in code

我只是一个虾纸丫 提交于 2019-12-04 07:20:27
I'm just starting with Devise and Rails3. I have the Authenetication down and working and understand the basics. As of now in my Home Controller that represents my Home/Front Page i have two links one that links to Register => sign_up and one that changes depending on login/logout => sign_in/sign_out. However i dont want to redirect my user to login page. Instead i want to display my login form on my front page. So i have seperated the devise/session/new template int to a view and a _form.html.erb partial. And now in my home view i render the login form as so: <% if user_signed_in? %> Welcome:

!! Unexpected error while processing request: failed to allocate memory

落爺英雄遲暮 提交于 2019-12-04 06:53:08
问题 Please help me in solving this error. I am getting this error while loading records from text files in to database using ruby scripts. It just works fine if I use small number of records to load in to the database.But fails if there are large number of records. CSV.foreach(fileName) do |line| completePath = line[0] num_of_bps = line[1] completePath = cluster_path+ '/' + completePath inode = FileOrFolder.find_by_fullpath(completePath, :select=>"id") metric_instance = MetricInstance.find(:first

Why Active Record relation is not returned in console?

≯℡__Kan透↙ 提交于 2019-12-04 06:49:58
I have finally started upgrading my Rails apps from 2.3.8 to 3.1.0. I was watching RailsCasts ( http://railscasts.com/episodes/202-active-record-queries-in-rails-3 ) about Active Record queries. When I open up the console (rails c) and do query similar to this: articles = Article.order("name") Instead of returning Active Record relations, I see the query executed. What am I doing wrong here? Rails version: 3.1.0 RVM on 1.9.2 Thank you for your help! EDIT: I have added a screenshot from the example. You're doing everything right. You see query executed because console invokes inspect method on

Running spec for a rails engine from its parent app

百般思念 提交于 2019-12-04 06:13:58
I have rspec suite for parent app, and also some spec for engines attached. What I want is to run them with one command. Is there a way to include my gems paths into rspec load path? Or should I write rake task for this? I think this is an interesting question, but my opinion is that Rails Engines should be treated as an independent code base and therefore not tested in your parent app. The effect is that you'd treat a Rails Engine in your parent app much like you treat other gems (EG, devise, which is actually a Rails Engine). But let's say you have parent app functionality that relies on a