I'm using paperclip in my rails 3 app to upload photos, resize with ImageMagick and then post to S3.
For the life of me, I can't figure out why this process is soooo slow on my localhost? Even without any resizing it's crazy slow... 30+ seconds for one photo?
And my network & cpu aren't even working hard?
Why?
Updating with Model:
c...
2 models
Books (has_many: chapters)
Chapters (belongs_to: books)
Id like to display a list of books, but only books with chapters.
Here's what I have so far:
@books = Book.find(:all,:include => :chapters)
Problem here is that books is returning books w/o chapters (0 chapters)
when dealing with nested resources like this, how do I ...
I am learning Rails, at the moment, but the answer doesn't have to be Rails specific.
So, as I understand it, a secure password system works like this:
User creates password
System encrypts password with an
encryption algorithm (say SHA2).
Store hash of encrypted pw in DB.
Upon login attempt:
User tries to login
System creates has...
I have a ruby (on rails) class:
class User < ActiveRecord::Base
# relationships
belongs_to :current_shipping_address, :class_name => "Address"
belongs_to :subscription
# Validators
validates_presence_of :subscription
validates_presence_of :current_shipping_address
end
I do this in a controller:
subscription = Subscriptio...
hi All,
Preface:
If you hang out in #rubyonrails on freenode this may sound like an echo to you as i asked it in there 2 days ago. After spending a number of hours researching AR associations, following my discussions in #rubyonrails, i still feel lost so I'm asking here. :)
Goal
I host a number of blogs. My intent is to create ba...
Hello,
I have the following two models:
class Project < ActiveRecord::Base
has_many :photoalbums
end
class PhotoAlbum < ActiveRecord::Base
belongs_to :space
end
routes.rb:
resources :projects do
resources :photo_albums
end
What I'm trying to do in the Controller is get a list of all the project's photoalbums:
class PhotoAl...
Hello,
I'd like my model's has_attached_file setting for paperclip to have a path as follows:
:path => "/:attachment/:instance_id/:id/:style/:basename.:extension",
so I setup a Paperclip.interpolates to obtain (:instance_id)
Paperclip.interpolates :instance_id do |attachment, style|
def user_id(attachment, style)
attachment.c...
I think I understand it as, if it is Rails 2.x
config.gem 'gem_name' # in config/environment.rb, and then rake gems:install
and in Rails 3.x
gem 'gem_name' # in Gemfile, and then bundle install
these are the two standard ways to add a gem into a Rails project.
Is there a standard way to add a plugin? It seems that it u...
Hello,
I'm still on the hunt for an elegant multi-file upload for Rails.
I just learned about the "input type=”file” multiple"
Does Rails support this? Any examples? tips on how to implement for uploading multiple photos to a photoalbum model in Rails?
Thanks
...
My App has two UI states:
- Signed IN
- Signed Out
I've been using the following to determine which app/view/layout to use based on if the user is signed in or out with Devise:
# Devise, way of using a different Layout for all the devise/non-signed in Views
layout :layout_by_resource
def layout_by_resource
if devise_control...
I'm using Rails 3.0.1, HAML 0.3.22, and Mongrel 1.1.5 (and MongoMapper not AR). I'm rendering a list, and each list item is it's own partial. Every time the page renders one of the list item partials takes almost 100X longer to render (and it is an arbitrarily different one each time. Also, needless to say, each item has essentially the ...
When I try to open my site on IE (development, environment, or online), it crashes every time. This is my server readout upon entering the home page (it actually crashes on any page view after this):
Rendered shared/_footer.erb (0.0ms)
Rendered welcome/index.html.erb within layouts/index (179.0ms)
Completed 200 OK in 204ms (Views: 203.0...
I have not gotten any errors with the tests up to this point so far, but I can't figure out these errors.
Failures:
1) PagesController GET 'home' should have the right title
Failure/Error: response.should have_selector("title",
undefined method `has_selector?' for #<ActionController::TestResponse:0x00000100ee9ed0>
#...
So what I'd like to do is to override the default date_select method (I'd like to make an 'optional / unspecified' date input). What I've tried so far is this:
lib/overrides.rb
ActionView::Helpers::DateHelper::DateTimeSelector.class_eval do
def build_selects_from_types(order)
select = ''
order.reverse.each do |type|
sep...
Currently I have an Order class. each order has 1 to infinite number of items. the number of items is not known until run time. since there is no field type of Array in active record / rails, how do you create a variable number of columns?
The only way I can think of is to specify a bunch of ticket columns ahead of time; but is very...
Hello, I have a nested model form for PhotoAlbums. The form works fine via the standard html. But what I need to do is render it as a partial in another page it's erroring: "No route matches
{:action=>"create", :controller=>"photo_albums"}"
The models:
Projects
has_many :photo_albums
PhotoAlbums
belongs_to :project
has_m...
I'm using the following form tag for @jobs which have job_photos included.
<% form_for @jobs, :html => { :multipart => true }, :remote => true do |f| %>
The form works fine non-remote, but if I add the remote = > true, the form submits, returns create.js but doesn't save anything to the DB or error?
...
I want to be able to override models and controllers of my rails 3 engine in the base app.
Inspecting $LOAD_PATH, I found engine's 'app/{models,controllers}' there, but I can't explicitly require engine's model or controller file: require 'engine_name/model_name' fails with "no such file" (tried with both namespaced(app/controllers/engi...
Hi,
I'm trying to get my rails3 app & gem taps & heroku to play nicely together. One googled solution is to use an earlier version of sequel. So I'd like to try to have bundler use sequel v3.13.0 instead of sequel v3.15.0, but bundler says:
You have requested:
sequel = 3.13.0
The bundle currently has sequel locked at 3.15.0.
Try runni...
I'm trying to build a new rails 3 app from scratch using OmniAuth. Currently I just have a completely empty app, where I've added omniauth to the Gemfile, and added a omniauth.rb in config/initializers that looks like this:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, 'APP_ID', 'APP_SECRET'
end
(E...