Rubymotion is starting to gain some real traction… looking forward to playing with it soon.

rubymotion:

We had the great pleasure to talk to Mark Villacampa about Cabify and their use of RubyMotion in production. Another great RubyMotion success story!

Hi Mark! Thanks for taking the time to talk to us. Could you introduce yourself?

I’m a 20 year-old Electronic Engineering student…

"When I eat, I use the utensil that best serves my needs. I do not ask silly questions, like whether a spoon is a liquid consumption device and a fork is a solids consumption device. I do not ask whether a knife does “real” work just because it does not, ordinarily, convey food to my mouth. I do not obsess on the exceptionally rare times when I may use my spoon as a fork, my fork as a knife or my knife as a fork. Instead, I simply use the right tool at the right time."

Sight from Sight Systems on Vimeo.

A peek at the future? Forget Google Glasses, this is way cooler.

(Source: zurb.com)

Chocolat just went 1.0 after many months of betas. I’ve been using Chocolat daily since a very early beta and was immediately hooked.  The developers were friendly and extremely active with feedback from their beta test community. The final product is something they can be very proud of. I jumped in a week before the version 1.0 countdown ended and purchased, and I couldn’t be more impressed. Congratulations to the team and thank you for building an viable alternative. Bye bye Textmate, I have a new best coding friend now.

minimalmac:

Can you imagine running Lion on an iPad, or booting a MacBook Air and seeing Launchpad instead of the Finder? Apple allows its hardware to help dictate what software is best suited for it. The company is willing to compromise on software features for a better user experience.

When Microsoft says “No compromises”, I hear “Can’t let go of the past.

iPhone 5? I think it looks more like the rear of an an iPad, but the size is too small.

My recent upgrade to OSX Lion has Textmate unsettled. :-(

In fact, it’s downright unstable. Textmate crashes several times a day, unexpectedly, sometimes simply just because I clicked on it. I find I can’t open projects from the Open… or the Open Recent commands in the File menu.

I also find switching between Textmate windows (open projects) using the Window menu simply doesn’t work. When I switch apps using the Command+Tab combination I find the Textmate menu fails to switch. Textmate gets the focus, but the menu is left behind. Only if I use the Command+Tab+Option key combination can I get the Textmate menu to get focus long with it’s window.

Other problems include having more than one Textmate window open in Lion’s new fullscreen mode. Switching between windows is impossible unless you swipe between fullscreen windows. Using key combinations or the Window menu do not work.

Textmate doesn’t seem to be compatible with Lion’s new Versions capability either.

I’ve tried removing the two plugins I have installed, GITMate and MissingDrawer. I’ve even tried a clean install. Unfortunately, this doesn’t improve it’s reliability.

I hope MacroMates are working on a Lion update for Textmate that addresses these issues and issues other’s are having. I’m really not happy with UX at the moment, and it won’t take me long to find an alternative, since this is a tool I need to use daily.

I’ve been mucking about with Active Admin, at times trying to bend it to my will. I’ve been frustrated as hell trying to get it to do some fairly simple stuff, and at times elated when I find a way to do it. The project documentation is, let’s say - progressing, and sometimes the best to work things out is to delve into the innards.

I had some success today while integrating the Paper Trail gem into my project. Paper Trail adds versioning of objects. It also permits you to switch to any version at any time, and record information about the nature of the version, for instance, who made the change.

In my project I don’t have a standard user, since the project is solely for administration, I have a manager model. Active Admin allows me to choose the model I want as a user object with Devise (for authentication):

# /config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
  config.authentication_method = :authenticate_manager!
  config.current_user_method = :current_manager
end

To integrate paper_trail, I need to tell it who the current user is, by default it’s looking for a method in the application controller called current_user. Since I don’t have a current user, instead I have a current manager, I need to override a method called user_for_paper_trail. This is typically done in the application controller.

Active Admin provides for a way to include before, after and around filters by adding them to it’s config. So I can include a before filter for the overridden method required by paper_trail in the config. This much is clear from the comments in the active_admin config file.

# /config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
  config.before_filter :user_for_paper_trail
end

What I was unclear about was where to put my method definition. I can’t simply put it in the ApplicationController as that is ignored by Active Admin. I assumed I had to override the admin controller in some way, and include the def block in the active_admin registration block for the model.

This is what I learned eventually, and it seems to work. I am able to wrap my method in a controller block, like this:

# /app/admin/posts.rb
ActiveAdmin.register Post do
  controller do
    def user_for_paper_trail
      current_manager
    end
  end
end

Not very DRY unfortunately because I have to repeat this for every model registration file in the admin folder where I need to override that method. It would be nice to have the ability to override methods in a single place - like the application controller. But it works for now.

justinreese:

You can now use images to search Google Images
justinreese:

You can now use images to search Google Images
justinreese:

You can now use images to search Google Images

justinreese:

You can now use images to search Google Images

Just add !! (a.k.a. the double bang operator) before any statement:

>> @document = Document.new
=> <Document id: nil, title: nil> >> @document.title
=> nil
>> !!@document.title
=> false >> @document.title = "My new document"
>> !!@document.title
=> true

In Rails, you can use the name of your…

iOS 5 for iPad?

I came across a new Ruby on Rails administration framework yesterday called Active Admin, thanks to the latest instalment (episode 165) of The Ruby Show

I was immediately impressed by the professional landing page and the look and feel of the administration views generated by the gem. I was also very impressed by the elegant DSL. Active Admin is packaged as a gem and it abstracts away all of the tedious administration coding into a simple DSL. The administration files are tucked away under the app folder into a folder of it’s own called admin, and there is one file per resource. I decided to give it a spin and see what it could do.

While playing around with it for an hour or so, I decided to see how far I could push it. Just how flexible is this framework. I added 15 resources to manage in the admin. This pushed the limit of visibility for the menu items at the top of the page, causing them to wrap. It looked ugly and where some resources were two of more words I found the menu item itself would break and wrap splitting the menu item over several lines. I noticed in the screenshot on the Active Admin web site that the Administration menu item had a disclosure indicator. This hinted that the menus could be nested, so I decided to look into it. I found some undocumented options on the menu method, one of which is :parent. By setting a parent you can nest menu items for resources under a top-level menu, and this creates a CSS dropdown menu.

This code generates an Administration menu with three menu items in a dropdown:

# app/admin/administration.rb

ActiveAdmin.register Manager do
  menu :parent => "Administration"
end

ActiveAdmin.register Backup do
  menu :parent => "Administration"
end

ActiveAdmin.register Setting do
  menu :parent => "Administration"
end

and it looks like this:

Another little thing that was slightly annoying was the attribution in the footer. There doesn’t seem to be provision to set the content displayed in the footer of the administration views. I’ve found that Ruby comes to your aid for things like this and by overriding the right method you can put whatever you want in the footer.

The following code overrides the footer content: 

# lib/active_admin_views_pages_base.rb

class ActiveAdmin::Views::Pages::Base < Arbre::HTML::Document

  private

  # Renders the content for the footer
  def build_footer
    div :id => "footer" do
      para "Copyright &copy; #{Date.today.year.to_s} #{link_to('Example.com', 'http://example.com')}. Powered by #{link_to('Active Admin', 'http://www.activeadmin.info')} #{ActiveAdmin::VERSION}".html_safe
    end
  end

end

# app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery
  
  # Override build_footer method in ActiveAdmin::Views::Pages
  require 'active_admin_views_pages_base.rb'
end

 

So far I haven’t found anything that’s restricting the way I want the administration views to function. I’ll be playing around with nested models and things like datetime pickers over the next day or so. I’ll post if I find anything tricky. I’m keen to hear your thoughts on Active Admin.

My desktop has received an update today:

  • Apple 13” MacBook Pro
  • Apple 27” LED Cinema Display
  • Apple Wireless Keyboard
  • Apple Magic Trackpad
  • Apple Battery Charger
  • Apple iPhone 4 and Dock
  • Western Digital 750GB USB HDD for TimeMachine hourly backups

All I can say is wow! You have to got experience this to understand.

Now I just need to find a nice set of headphones - preferably wireless!

  1. Camera: iPhone 4
  2. Aperture: f/2.8
  3. Exposure: 1/40th
  4. Focal Length: 3mm

This has to be one of the funniest sites I’ve seen in a long time! DamnYouAutoCorrect.com

I was recently impressed by Ryan Bates recent Railscast on Undo with Paper Trail, but faced a few difficulties trying to port it into a Rails 2.3.8 project.

Rails 3+ has access to the view_context in the controller. It took me a while to find this because I’ve never needed it, but Rails 2.3.8 has similar access to the link_to helper via @template.

I also found that the undo action taken immediately after a create caused an Activerecord::RecordNotFound error, caused by a redirect_to the show action of the record that was just destroyed.

After fixing these issues I decided to fork Ryan’s source and provide a Rails 2.3.8 version. You can find this at https://github.com/MeetDom/railscasts-episodes/tree/rails238/episode-255. I hope someone else finds this useful.