background preloader

Open Source Rails

Open Source Rails

Posting to Twitter from a Ruby on Rails App | ckdake.com Similar to Tuesday's Posting to Facebook post, here is how to link a model in a Ruby on Rails app with Twitter and post to Twitter. This one does the exact same thing, but of course needs to use different code because everyone implements OAuth differently. To post to Twitter, I use the OAuth gem to connect, and the Twitter Gem to do posting. Note that this uses the 1.0 version of the Twitter gem which is not yet released, so the Gemfile pulls it from Github directly. Read The Twitter Docs, specifically the Twitter OAuth Docs. The basic flow here for the user is the same as with Facebook: User visits twitter_account/new when they want to link in TwitterThey get redirected to the allow/deny page on Twitter that prompts the user to log in and accept your applicationAssuming they accept, they get redirected back to callback/twitter/ with an oauth_token that we use to look up the TwitterAccount (a nice feature that Facebook doesn't do!) Run "bundle install" and set up the routes:

gitlabhq/gitlabhq Groupes d'utilisateurs Les groupes d’utilisateurs sont des mini-réseaux regroupant des programmeurs par centre d’intérêt ou langue. Rejoindre et participer à un groupe est une manière très efficace d’améliorer ses compétences et de rencontrer d’autres programmeurs. Les groupes sont informels, au sens que leur structure varient d’un groupe à un autre : certains consistent en une simple liste de diffusion ou un forum, d’autres ont une assise légale (association…) et organisent éventuellement des rencontres et des conférences. Groupes Pour rencontrer d’autres programmeurs Ruby, un groupe local (au sens de la géographie) peut être un bon moyen de progresser, à condition d’en avoir un près de chez vous. Ruby France L’association française de promotion du language Ruby fédère un certains nombre de groupes locaux (Paris, Lyon…) et constitue par elle-même un groupe d’utilisateurs, centré autour de la liste de diffusion publique. Meetup Paris Le groupe d’utilisateurs Paris.rb organise des apéros et des sessions de code.

Loading a single fixture in rails. | stew (@) rtmatheson.com UPDATE: At the time of this posting I did not know that there was already a way to do this in rails but thanks to Robert Siemieniec for letting me know. rake db:fixtures:load FIXTURES=name_of_fix_file,name_of_other_fix_file So just use this in the future. My solution still works if you wanted to have a separate rake task. However honestly there is no point just go with what rails has out of the box. If you really want to have your own rake task then read on. namespace :db do namespace :fixtures do desc "Load a single fixture by setting FIXTURE=name of fixture you wish to laod." task :load_single => :environment do require 'active_record/fixtures' ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[RAILS_ENV]) Fixtures.create_fixtures("test/fixtures", [ENV['FIXTURE']]) puts "Fixture #{ENV['FIXTURE']} loaded in to #{RAILS_ENV} environment." end end end Usage… rake db:fixtures:load_single FIXTURES=questions

ChiliProject - Homepage - ChiliProject Ruby on Rails Tutorial: Learn Rails by Example book and screencasts by Michael Hartl | Filling In The Layout Michael Hartl Contents Foreword My former company (CD Baby) was one of the first to loudly switch to Ruby on Rails, and then even more loudly switch back to PHP (Google me to read about the drama). This book by Michael Hartl came so highly recommended that I had to try it, and the Ruby on Rails Tutorial is what I used to switch back to Rails again. Though I’ve worked my way through many Rails books, this is the one that finally made me “get” it. The linear narrative is such a great format. Enjoy! Derek Sivers (sivers.org) Founder, CD Baby Acknowledgments The Ruby on Rails Tutorial owes a lot to my previous Rails book, RailsSpace, and hence to my coauthor Aurelius Prochazka. I’d like to acknowledge a long list of Rubyists who have taught and inspired me over the years: David Heinemeier Hansson, Yehuda Katz, Carl Lerche, Jeremy Kemper, Xavier Noria, Ryan Bates, Geoffrey Grosenbach, Peter Cooper, Matt Aimonetti, Gregg Pollack, Wayne E. About the author Copyright and license 5.1.1 Site navigation <!

Use memoization Memoization is an optimization technique used primarily to speed up computer programs by having function call avoid repeat the calculation of results for previously-processed input. Here I will give you an example. Problem Imagine you have a billing system that one user has many accounts, each account has its own budget, there is a method total_budget for user object, which calculate the summary of all the available accounts' budgets. The following is the model definition. class User < ActiveRecord::Base has_many :available_accounts, :class_name => 'Account', :conditions => "budget > 0" def total_budget self.available_accounts.inject(0) { |sum, a| sum += a.budget } endend total_budget will be used multiple times in models, views and controllers, such as <% if current_user.total_budget > 0 %><%= current_user.total_budget %><% end %> Caching with instance variable There is an easy solution to use caching with instance variable to avoid the duplication execution. def has_comment? Memoizable

Tuning Phusion Passenger’s concurrency settings Phusion Passenger turns Apache and Nginx into a full-featured application server for Ruby and Python web apps. It has a strong focus on ease of use, stability and performance. Phusion Passenger is built on top of tried-and-true, battle-hardened Unix technologies, yet at the same time introduces innovations not found in most traditional Unix servers. Since mid-2012, it aims to be the ultimate polyglot application server. We recently received a support inquiry from a Phusion Passenger Enterprise customer regarding excessive process creation activity. The customer then raised the question: what is the best value for PassengerMaxPoolSize? For simplicity reasons, we assume that your server only hosts 1 web application. Aspects of concurrency tuning The goal of tuning is usually to maximize throughput. Memory. With these in mind, we give the following tuning recommendations. Tuning the application process and thread count Step 1: determine the system’s limits This formula is derived as follows:

Installer Ruby on Rails 3 sans peine et sans danger sous Mac OS X Une méthode pour installer Ruby on Rails et ses dépendances parallèlement à votre environnement de développement habituel, afin de ne courir aucun risque. Avec la sortie de la bêta de Ruby on Rails 3.0, il est temps de commencer à porter doucement vos applications vers cette nouvelle version majeure de votre framework Web favori. Parce que Ruby on Rails 3.0 ne supporte plus les versions de Ruby antérieures à la 1.8.7, l'installer risque fort de casser votre environnement de développement habituel. Avec ce didacticiel, je vous propose d'installer Ruby, Rails et leurs dépendances parallèlement à votre environnement de développement habituel afin de ne courir aucun risque. Notez que s'il a été écrit spécifiquement pour Mac OS X, il est à priori également valable sous la majorité des UNIX. Mettre à jour votre version de Ruby Commencez par télécharger la dernière version stable de Ruby. curl -O xvzf stable-snapshot.tar.gzcd ruby .

Successful Freelancing With Ruby On Rails: Workflow, Techniques And Tools - Smashing Magazine Advertisement Warning: Freelancing Is Not for Everyone A freelancer is a self-employed person who pursues a profession without a long-term commitment to any particular employer. Your curiosity in this opportunity was probably sparked by posts marked “Freelance” or “Work from anywhere” on the myriad of job boards around the Web. Freelancing is equal parts freedom and responsibility. While you have the freedom to choose when you work, where you work and what you work on, you are also responsible for everything: deadlines, finding work, the quality of your work, communication and so much more. Photo by Dmitry Belitsky Ruby, with all of its frameworks and libraries (such as Rails, Merb and Sinatra), is a practical tool to use in your freelance Web development career because of its focus on clean code, object-oriented syntax, efficient development practices and strong community (whether a simple IRC chat room or large conference). Pros Photo by Giorgio Montersino. Be your own boss. Cons Job Boards

Related: