i needed to use 2 different classes to get this to work in my project. this was a good explanation but wouldn't work for me since I was already using carrierwave on a live site and had images uploaded to specific folders already on S3. What I did was created an uploader class ImageUploader using the CarrierWave_Direct gem like in this example, and then kept my original class but renamed it to ImageProcessor. This way the original uploaded file is saved in a different folder in S3 and then I don't have to change the folder structure for current photos on my site. you can check out my solution here if interested:
I've had some luck placing angular "apps" into separate partials that can be accessed as templates by AngularJS. If Rails renders server side, real data is used. If angular requests the "partial" via Ajax, I give it sample data that is removed when Angular binds to the template.
Thanks for the simple contribution! I've never messed with coffescript before and I'd have had no idea that spaces instead of tabs would mess my code up so much!
I have solved this same problem using a column where I store the original locale, and overriding a method set in Globalize3::ActiveRecord::InstanceMethods. Here is the code:
def globalize_fallbacks(locale)
if record_fallback?(locale)
[locale, original_locale]
else
Globalize.fallbacks(locale)
end
end
def record_fallback?(locale)
respond_to?("original_locale") and
original_locale.present? and
original_locale != locale
end
It works fine. I don't know if there is any downside...
@Nic - I know your question is very old, but if you want to integrate Rails with Open Directory Apple has some example code. Unfortunately you need to own OS X Server to view it. Apple uses Ruby on Rails to implement their wiki server and profile manager applications. Dig in to the Server.app bundler and look for a folder called webauthd. The ruby code for md5 authentication with Open Directory is in that folder.
It's true that understanding the inner workings of frameworks is very valuable. I was quite excited when I saw this railscast for that very reason. The problem is that zipping through a large number of classes & modules scattered about a number of unfamiliar files at high speed is simply not useful in learning Rails internals.
You are so right, I have tried AngularJS in the past and it's obstrusive if you want the two way data binding with Backbone use rivets.js, you can check an example I have done http://boriscy.github.com/backbone-rivetsjs/
I'd like to second that. I spent an hour fiddling with Taps. I was done with my intended task five minutes after hearing this post about valkyrie. Just lovely. Thanks!
Hi Ryan!
It will be great if you can make a screencast showing us how to deploy an app on 2 servers, one for the Rails app itself and the other one for the database( Postgres). This is probably the first step I might do when I want to scale an app, but still, I can't find materials about how to do it right.
Thanks Sanjeev,,,for those who don't notice the subtle difference... Morris.Line({....}) needs to separate each different chart/graph call with different tags...otherwise it will only see the first and you'll get the "'Graph Placeholder not found'" or "Element not found" errors.
Hi Daniel , had the same problem. In your controller if you have a respond block you have to add respond_to js. If you dont have a respond block it will look for js.erb automatically.
but it seems to work if you pass @products as a variable into the model by adding it in the parentheses and in the .each loop as I'm passing all_products in below.
product.rb
defself.to_csv(all_products)
CSV.generate do |csv|
csv << column_names
all_products.each do |product|
csv << user.attributes.values_at(*column_names)
endendend
The advantage is that you can define @products in the controller in order to only get the products you want such as in this example:
products_controller.rb
@products = Product.find_all_by_color("green")
respond_to do |format|
format.csv { send_data User.to_csv(@products) }
end
i needed to use 2 different classes to get this to work in my project. this was a good explanation but wouldn't work for me since I was already using carrierwave on a live site and had images uploaded to specific folders already on S3. What I did was created an uploader class ImageUploader using the CarrierWave_Direct gem like in this example, and then kept my original class but renamed it to ImageProcessor. This way the original uploaded file is saved in a different folder in S3 and then I don't have to change the folder structure for current photos on my site. you can check out my solution here if interested:
http://stackoverflow.com/questions/14791655/carrierwave-direct-gem-keep-current-directory-structure-on-s3/14842832#14842832
I've had some luck placing angular "apps" into separate partials that can be accessed as templates by AngularJS. If Rails renders server side, real data is used. If angular requests the "partial" via Ajax, I give it sample data that is removed when Angular binds to the template.
Thank you Luke for mentioning that!
Yeah, that is a really great explanation. Thanks.
I've successfully built it for Lion with Xcode. I just needed to replace the Deployment Target from 10.8 to 10.7
Here is the link:
https://dl.dropbox.com/u/9189157/SublHandler.zip
Thanks for the simple contribution! I've never messed with coffescript before and I'd have had no idea that spaces instead of tabs would mess my code up so much!
I have solved this same problem using a column where I store the original locale, and overriding a method set in Globalize3::ActiveRecord::InstanceMethods. Here is the code:
It works fine. I don't know if there is any downside...
Here's another nice gem that can handle exporting data to CSV, Excel, JSON, and HTML:
Dossier
https://github.com/adamhunter/dossier
thanks a lot! (works with FireFox and Chrome)
@Nic - I know your question is very old, but if you want to integrate Rails with Open Directory Apple has some example code. Unfortunately you need to own OS X Server to view it. Apple uses Ruby on Rails to implement their wiki server and profile manager applications. Dig in to the Server.app bundler and look for a folder called webauthd. The ruby code for md5 authentication with Open Directory is in that folder.
Sorry, better use this:
<%= edit_password_reset_path(@user.password_reset_token, :locale => "#{I18n.locale}") %>
what is the best way to load seed data for a new tenant?
how about adding load Rails.root.join("db/seed_tenant#{id}.rb") to create_schema:
def create_schema
connection.execute("create schema tenant#{id}")
scope_schema do
load Rails.root.join("db/schema.rb")
load Rails.root.join("db/seed_tenant#{id}.rb")
connection.execute("drop table #{self.class.table_name}")
end
end
The filename is not getting set using your method. Is there a different way to set the filename?
For anyone who is working with different locales (like Remmington above), make sure your mailer template looks something like this:
<%= edit_password_reset_path(@user, :locale => I18n.locale, :password_reset_token => @user.password_reset_token) %>
Especially when you have routes like these:
It took me ages to figure that out...
I just tested this app and can confirm your assumption. It kept on recreating the thumbnails.
It's true that understanding the inner workings of frameworks is very valuable. I was quite excited when I saw this railscast for that very reason. The problem is that zipping through a large number of classes & modules scattered about a number of unfamiliar files at high speed is simply not useful in learning Rails internals.
i M HAVING SAME ISSUE
I just merged the nested_urls branch to master and released a 0.1.0 version of the gem with that functionality included.
Make this change in routes. And it works.
resources :styles do
collection do
match 'search' => 'styles#index', :via => [:get, :post], :as => :search
end
end
Great Cast!
FYI, Bootstrap components written in pure AngularJS:
http://angular-ui.github.com/bootstrap/
+1 on this suggestion
Another Awesome screencast! Very nice Mr. Bates.
Hi
I am trying to use will_paginate with ransack.
controller
@search = Style.search(params[:q])
@styles = @search.result(:distinct => true).paginate(:page => params[:page], :per_page => 5)
index
<%= will_paginate @styles %>
Rest of the code is same as in this tutorial. But pagination links are not working. Really stuck with it. Please help.
Thanks for the post Ryan, you don't have any idea how much you helped me so far. :)
By the way,
rails g spree:site
is not the generator right now. It israils g spree:install
anymore.Thanks Jaroslaw for the quick but important tip about Node.Js I want to look at Joosy too.
Thank you Travis for this information. TodoMVC will help me, i assume, in the near feature.
+1 for a follow-up railscast!
It is not working for me. I used both FireFox and Chrome, and I click on "Launch App", but nothing happens
You are so right, I have tried AngularJS in the past and it's obstrusive if you want the two way data binding with Backbone use rivets.js, you can check an example I have done http://boriscy.github.com/backbone-rivetsjs/
The different parameters and the jQuery don't seem to work together for me. Do you guys have any idea why this happens?
http://stackoverflow.com/questions/14569721/rails-parameters-get-lost-because-of-jquery-link
By the way: since jQuery 1.9 it is ".on("click", function()" instead of ".live("click", function()".
Thanks Michael. Exactly what I was looking for.
Hi can you help me
I'm trying to open rails console and getting this
deployer@microv:~$ rails console
-bash: rails: command not found
For Better Errors, Sublime Text 2 and Ubuntu see https://gist.github.com/wojtha/4749450
Thanks !
thanks a lot of your help ,,It will be y pleasure to contact you
See Sanjeev's and my replies below
See Sanjeev's and my replies below
Agree! I don't like cluttered views. I feel Backbone is a more elegant and unobtrusive solution.
I'm having trouble moving the code that generates the pdf from the controller to a separate ruby file.
I have the following code in the relevant part of my controller:
I created a separate certificate_pdf.rb file in the folder app/pdfs which contains the following code:
However, when I open the generated pdf the document is blank. Any thougths?
Thanks for this.
I'd like to second that. I spent an hour fiddling with Taps. I was done with my intended task five minutes after hearing this post about valkyrie. Just lovely. Thanks!
Hi Ryan!
It will be great if you can make a screencast showing us how to deploy an app on 2 servers, one for the Rails app itself and the other one for the database( Postgres). This is probably the first step I might do when I want to scale an app, but still, I can't find materials about how to do it right.
Thank you!
Im struggling to get this solution to start with the environment set as staging.
I have tried updating the unicorn init file to pass the -E argument:
CMD="cd <%= current_path %>; bundle exec unicorn -D -c <%= unicorn_config %> -E <%= stage %>"
But Rails.env always says production.
Any ideas?
Anyone tried this setup with SSL? I'm getting pretty tripped up with this config.
I added:
To the trinidad config block.
However trinidad continues to looks for the keystore file instead of using the certs.
Thanks Sanjeev,,,for those who don't notice the subtle difference... Morris.Line({....}) needs to separate each different chart/graph call with different tags...otherwise it will only see the first and you'll get the "'Graph Placeholder not found'" or "Element not found" errors.
Hi Daniel , had the same problem. In your controller if you have a respond block you have to add respond_to js. If you dont have a respond block it will look for js.erb automatically.
+1 I was actually a bit surprised to see an angular screencast before an ember screencast.
Any comments on
Meteor
? is it still far from a JS framework for production?I got the same "can't convert Array into Hash" error from
but it seems to work if you pass @products as a variable into the model by adding it in the parentheses and in the .each loop as I'm passing all_products in below.
The advantage is that you can define @products in the controller in order to only get the products you want such as in this example:
Now Ryan, if you can just change this from products to personnel records and add workflows, the app I need to write will be done.
Thanks again, Ryan.