Showing posts with label rails. Show all posts
Showing posts with label rails. Show all posts

2008/12/24

Merb + Rails merger























Update(2009.2.8)
"Merb in Action" => "Rails3 in Action"
http://www.manning.com/katz/

Table of Contents
1. Building Your First Rails 3.0 Application
2. Overview of the Rails stack(s) + architecture
3. Creating Rails Applications
4. Using DataMapper for Models
5. Using ActiveRecord for Models
6. Other Choices for Models
7. Processing Requests
8. Routing in Rails 3
9. Customizing Views
10. Working on the Client Side
11. Supporting Characters
12. Using the Plugin API
13. Testing Your Applications
14. Deploying a Rails Application
15. Scaling Rails

Appendix A Just enough advanced Ruby
Appendix B The migration story
Appendix C Rails 2 to Rails 3
Appendix D Merb 1 to Rails 3

Update(2009.2.5)
Rails 3 will have mountable applications, not engines or slices.

Update(2009.1.16)
I just got an email from manning about "Merb in Action".
  • Rails becomes more modular, by building on rails-core with the ability to opt in or out of specific components and making it possible to replace parts of Rails without disturbing other parts.
  • Merb performance improvements flow into Rails, including benchmarking applications so developers can see which optimizations have real-world impact.
  • A defined public API with a test suite, so users and plugin developers have a stable API to build against.
  • A "core" version of Rails, like Merb's current core generator, that makes it easy to select just the parts that are important for your app.
  • DataMapper and Sequel support as first-class ORMs, along with ActiveRecord as the default.
  • Rack support in Rails 3, to improve the state of modular, sharable logic between applications.
Update(2008/12/26)
So far, it seems that merb google group is the best source. And Matt Aimonetti answers all the concerns.

Yehuda Katz says
"If you want to learn Merb for modularity and power that is not currently present in Rails, stick with Merb. We'll provide a good upgrade path to Rails3 (and feel free to contact me personally to keep me honest on that promise), and you'll have a leg-up when the same power makes its way into Rails. While Rails3 will still be very similar to Rails2 for current Rails users, it will look a lot like Merb for those users who are currently drawn to Merb."

"We always said that there would be breaking changes in Merb 2.0. Now, some of those breaking changes will be in tandem with the Rails3 merger. However, we will treat them like any other breaking changes, and make sure the deprecation notices flow freely and the transition path is clean. Make sense?"

Matt Aimonetti says,
"The great advantage of using merb now, is that it has a public API so we will be able to easily migrate it to the new 3.0 API. Concretely, we are planning on being able to replace merb-core by rails-core in your merb app and to use merb-helpers and other plugins with rails-core."


I think "Merb in Action" would take longer than expected. And it's required to rewrite the whole chapters that are published. Of course, book's title will not be changed but I'm just worried about Merb. It would be called Rails3.0 by many other people, especially inside Rails community.

As Ezra said,
Merb is dead, long live Merb(Rails-3.0)!
Matt Aimonetti said,
I don't think Ezra is right. Merb isn't dead. First off, merb will still be around until the next release (rails 3.0) and we will keep on supporting it even after that (maintenance).
So many merbists are disappointed by this news but there is nothing can be done. Engin Yard's decision looks solid. I've accepted it, after all. I've read many articles enough to say that I will stick with Merb. There were some people who even want to switch to Django. I decided to practice Merb more than before. Because Merb would be the core changes in Rails3. And it could happen that Merb core team is too busy. But evangelist like Matt Aimonetti will help us. I hope taking this path would be natural to Merb2.

2008/01/25

cygwin, Rails2, OpenID 2

Hi, I've been googling about a week to solve a ruby-openid problem. And found a working example on Rama McIntosh's blog. http://myutil.com/2007/12/29/openid-2-0-2-with-rails-2-0-2

At first, I thought rails Ticket #10604 patch worked. But it was more complicated than that. Since Rails, ruby-openid, and open_id_authentication plugin versions were not consistent. And Rama McIntosh went through all. You can find Dr. Nick’s example application fully ported to rails 2.0.2.
Here is my development environment. 
------------------------------------------------------------
LG LW25 advanced laptop IntelCore2 T5600, Mem 2G
XP Pro version2002 SP2
Cygwin + CygPutty 
Ruby ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-cygwin]
Rails 2.0.2
ruby-openid (2.0.3)
rake (0.8.1)
mongrel (1.1.3)
mongrel_cluster (1.0.5)
ruby-yadis (0.3.4)
app db : sqlite3
------------------------------------------------------------
Besides his README, some extra typing was needed to run the app.
1. svn co http://drnicwilliams.com/svn/openid/demos/apps/openidauth_multiopenid/trunk openidauth_multiopenid
 
2. Do not erase some svn directories because he made some rake tasks related with svn.
3. rake freeze TWICE!
4. mkdir log
5. require_gem => gem
openidauth_multiopenid/vendor/gems/ruby-openid-1.1.4/lib/openid/service.rb:7
openidauth_multiopenid/vendor/gems/ruby-openid-1.1.4/lib/openid/discovery.rb:8:
6 rake db:create
7. gem install mocha
8. rake test
9. config/environment.rb
  config.action_controller.session = { :session_key => "_openidauth_multiopenid_session", :secret => "mocramagic" }
  
  Replace to other {key, secret} like this,
  
    config.action_controller.session = {
    :session_key => '_foo_session',
    :secret      => '4747ba80asdfqwertwertwee5y4365345ertf gadrtvrwebterwvd653b65tyt93c45cb53242eb43'
  }
10. mongrel_rails start!!

2008/01/16

Gusty, Nginx, Rails and Mongrel_cluster howto

Here are the articles where I learned proper way to do this.

sudo cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/mongrel_cluster

Next, add a path statement to mongrel_cluster file just above the CONF_DIR variable:
sudo vi /etc/init.d/mongrel_cluster

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin
USER=mongrel to USER=www-data

sudo chmod +x /etc/init.d/mongrel_cluster
sudo update-rc.d mongrel_cluster defaults

In our rails app directory we need to create our mongrel config and then symlink it to where our mongrel config directory located at /etc/mongrel_cluster.

nano config/mongrel_cluster.yml

cwd: /var/www/rails/coredrill
log_file: log/mongrel.log
port: 8000
environment: production
group: www-data
user: mongrel
address: 127.0.0.1
pid_file: tmp/pids/mongrel.pid
servers: 3


ln -s /var/www/rails/coredrill/config/mongrel_cluster.yaml /etc/mongrel_cluster/coredrill.yaml

Starting nginx: 2008/01/15 23:17:19 [warn] 3238#0: conflicting server
name "coredrill.wowdns.com" on 37.208.125.80:80, ignored
==>
You have to add this to your default vhost:

server_name _ *;
listen 8080 default;


Finally, check your vhost config.
server
{ 
 listen 37.208.125.80:80; => listen 8080;
...
}
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default



mongrel_rails start -d -e production -p 8000 -P log/mongrel8000.pid 
mongrel_rails start -d -e production -p 8001 -P log/mongrel8001.pid 
mongrel_rails cluster::start 
mongrel_cluster_ctl status

2008/01/10

attachment_fu on Windows

http://railsforum.com/viewtopic.php?id=6307
Code :   - fold - unfold
  1.       def uploaded_data=(file_data)
  2.         return nil if file_data.nil? || file_data.size == 0
  3.         self.size = file_data.size
  4.         self.content_type = file_data.content_type
  5.         self.filename     = file_data.original_filename if respond_to?(:filename)
  6.         if file_data.is_a?(StringIO)
  7.           file_data.rewind
  8.           self.temp_data = file_data.read
  9.         else
  10.           self.temp_path = file_data.path
  11.         end
  12.       end
and added conditionals for the size
      

Code :   - fold - unfold
  1.       def set_size_from_temp_path
  2.           self.size = File.size(temp_path) if save_attachment? && (self.size == 0 || self.size.nil?)
  3.       end

Posted by Adam (Guest) 
on 10.04.2007 01:34
http://www.ruby-forum.com/topic/99870
To get things working with S3 and windows, I changed:        def temp_data         if save_attachment?           f = File.new( temp_path )           f.binmode           return f.read         else           return nil         end       end (before, the method body was save_attachment? ? File.read( temp_path ) :  nil  ) 

2008/01/09

Rails2.0 and heroku the awesome rails app hosting



Check it out. It's free and looks cool. I was frustrated by googling free rails hosting all day. Of course there're many hosting sites with shining options. But for testing, it's too expensive. Anyway I found the heroku.com. With Rails2.0 and Amazon S3, this site will dominate all the other hosting sites. Why? because they'll support Gems & Plugins Manager which made me annoying.

There're also some screencasts.

So, for now you'd better freeze your gems by using Dr Nic's Gems on Rails.

To install the plugin:

> gem install gemsonrails > cd rails-app-folder > gemsonrails 

Usage:

rake gems:freeze   GEM=gem_to_freeze rake gems:link     GEM=gem_to_link rake gems:unfreeze GEM=gem_to_unfreeze_or_unlink
gem install gemsonrails cd app-folder gemsonrails rake gems:freeze GEM=ruby-net-ldap


(Though freezed gem does not work properly now)