h1

10 Things you want to know if you start with heroku.com

September 15, 2009

1. start with reading how to use git (http://en.wikipedia.org/wiki/Git_%28software%29)

2. create your local git repository (git init)

3. get a free heroku.com account

4. install the heroku gem (gem install heroku)

5. add your files (git add .)

6. commit your files (git commit -m “my new app”)

7. create your app @ heroku (heroku create) –> public key needed!

8. push your app to heroku (git push heroku master)

9. check the output (heroku logs)

10. add needed gems (create a .gems file in your folder and add it to the repository, each gem a new line e.g. hpricot)

11. get more Infos @ heroku (http://docs.heroku.com/)

h1

ActiveRecord::Errors.new(self) and undefined method self_and_descendants_from_active_record

September 9, 2009

We recently switched to rails 2.3.4 and noticed the following error:

undefined method self_and_descendants_from_active_record for Cart:Class

Our Cart class has no ActiveRecord binding, but we need some validations, so we simple use

@errors = ActiveRecord::Errors.new(self)

and overerride the valid? action.

But now we get the undefined method error.

Solution

Implement in your class also:

 def self.self_and_descendants_from_active_record
    [self]
  end

  def self.human_name(options = {})
    defaults = self_and_descendants_from_active_record.map do |klass|
      :"#{klass.name.underscore}"
    end
    defaults < [:activerecord, :models], :count => 1, :default => defaults}.merge(options))
  end

  def self.human_attribute_name(attribute_key_name, options = {})
    defaults = self_and_descendants_from_active_record.map do |klass|
      :"#{klass.name.underscore}.#{attribute_key_name}"
    end
    defaults << options[:default] if options[:default]
    defaults.flatten!
    defaults < defaults, :scope => [:activerecord, :attributes]))
  end

and you can still use ActiveModel like validations :)

h1

javascript value and rails I18n

September 8, 2009

Today i stumble about the following problem, i have a javascript value and want it inside a localized rails string.

“This is my string javascriptvalue and so on …”

solution

'<%= T("This is my string ## and so on ...", :translate_string) %>'.sub(/##/, javascript_value);

i simple use javascript sub to replace ## with the javascript_value.

:)

h1

Switch to Mac

Mai 9, 2009

Vor einer Woche habe auch ich den Schritt zu Apple gewagt und mir ein “generalüberholtes” MacBook geleistet.

Im Moment bin ich noch am einrichten / konfigurieren / Programme suchen, aber alles in allem ist es doch schön eine voll funktionsfähige Konsole zur Verfügung zu haben und den komfort einer schönen Oberfläche.

Allen Rails Entwicklern sei der folgende Artikel ans Herz gelegt:

http://giantrobots.thoughtbot.com/2009/3/30/2009-rubyist-guide-mac-os-x-development-environment

(Achtung: MySQL auch wirklich in der 32 Bit Version installieren!)

Als IDE empfehle ich Netbeans in der Version 6.7, auch wenn sich diese noch im Beta Stadium befindet.

So, und nun begebe ich mich noch auf die Suche nach einem einfachen Bildbearbeitungsprogramm ;-)

h1

CentOS and mod_rails – failed to map segment from shared object: Permission denied

April 6, 2009

After some playing with VirtualBox and CentOS i try to install mod_rails, all in all no big deal, but if i try to start / restart httpd service i got:

Stopping httpd: [FAILED]
Starting httpd: httpd: Syntax error on line 1of /etc/httpd/conf/
rails.conf: Cannot load /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/
passenger-2.1.2/ext/apache2/mod_passenger.so into server: /opt/ruby-
enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.2/ext/apache2/
mod_passenger.so: failed to map segment from shared object: Permission
denied [FAILED]

Solution:
Disable SELinux, or have a closer look to the docs.

h1

sortable_element with table

März 24, 2009
<table class="listing">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody id="project_versions">
<% for item in project_versions %>
  <% content_tag_for(:tr, item) do %>
<td class="drag_handle">[drag]</td>
<td><%= h item.name -%></span>
  <% end %>
<% end %>

 <%= sortable_element('project_versions', :url => {:controller => 'project', :action => 'sort_project_version'}, :handle => :drag_handle, :tag => :tr) %>

Without many words, i hope the code speaks for itself.
Take care of the :tag attriubte in the helper (default is li) and the container has to be the tbody.

h1

Selling Rails in a Recession

März 5, 2009

According to this grailsblog post, here is the Rails port:

Open Source Stack = $0

Because Rails runs on the JVM (JRuby), it is platform agnostic and capable of running on top of a 100% open source stack. Everything including the OS, app server, and database may be obtained free of charge with no license fees.

Faster Development Time

Yes, it’s great that everything needed to run Rails’ applications may be obtained for free, but what’s even a bigger cost savings is how much time developers can save by working within the JRuby/Rails environment. Rails really tends to speed up development in the following 3 areas:

Data Access

ActiveRecord provides an amazingly efficient way to model domain objects as well as persist them to a database.

Scaffolding

Scaffolding speeds up development time rapidly.

Syntax

When working with JRuby and Rails, developers will find themselves writing less code than when working within the traditional Java environment. Less code translates into shorter development time.

Summary

Rails is a great fit for a recession. It allows developers to create high quality applications on top of a free open source stack in less time than many of the more common, corporate frameworks.

Follow

Erhalte jeden neuen Beitrag in deinen Posteingang.