Use before_destroy on a model with paperclip


I have an application that I’m working on, this application has a demand that I will show the total files and the file total size inside a project. Here is my model: Of course I have the option of using joins and so on and then calculating the file size, but because every project has many folders and every folder has many attachments this seems a bit off and not straight forward.…
Read more ⟶

Use token instead of id in paperclip’s path


I have been using paperclip in more then a couple of applications that I’m developing now, I really like it and it gives me the flexibility that I require.Url with Token exampleA couple of days ago, I wanted the path of the file to include a token instead of the id of a user class. This was my code before the change: has\_attached\_file :avatar, :styles => { :tiny => "48×48>", :preview => "175×175>", :large => "300×300>", :huge => "500×500>" }, :storage => :s3, :s3\_credentials => "#{RAILS\_ROOT}/config/s3.…
Read more ⟶

Removing a model from your rails project


During the work on a project I created a model. Right after clicking the Enter key I realized that I didn’t need it and wanted to roll back. Because I am using GIT, I could of course have done this using it, but I wanted to do it using a Rails command. Turns out, there’s a command to do this (if you haven’t migrated the db yet). The command is as follows:…
Read more ⟶

A solution for the “I Follow” bug with cucumber and Capybara


While working on a new application and writing tests I encountered a problem: This is the test I have been using: [ruby] Scenario: Deleting a project from the main page Given I am on the account home page When I follow “Delete Project” Then I should see “Your project has been deleted” [/ruby] The error that was shown is this: [shell] undefined local variable or method `node’ for #<Capybara::Driver::Node tag=“a” ……
Read more ⟶

Pluralization in flex application(s)


As you may know (or not) I am a Flex developer, I am also a Ruby On Rails developer. As a Ruby On Rails developer I often find myself hoping just a fraction of the stuff Ruby On Rails has would come to Flex or someone will port parts of it to Action Script 3. This week I had a bug reported by a client that the alerts he received from the systems are inconsistent to the amount of items he is selecting.…
Read more ⟶

Scroll to selected index in Tree control (Flex)


Sometimes, in your application you have a tree that has many nodes, folders, sub-folders and many items. Often, this tree needs to have a scroll bar, and usually you want the scroll to be on the spot with the selected item. I recently encountered some weird solutions for this in a company I work for these days, I have actually seen a custom control with saving the scroll position in memory, height calculations for items and many more “solutions”.…
Read more ⟶

Make your life easier with this Flash Builder 4 plugin (sourcemate)


I have been working with flex for about 4 years now and moved to Flash Builder 4 about six months ago. The one thing I have really missed in programming flex is the proper IDE that makes your life easier, making simple tasks simple for the programmer. For instance, I always wanted to write private vars (with shortcuts) and then make getters and setter with a click of a button, with no real need for typing them all.…
Read more ⟶

gitignore template for a Ruby on Rail project


Been working with Ruby On Rails for about 10 months now, about the same amount of time with GIT, I enjoy them both very much. When I start a rails project and connect it to GIT, I always create the same gitignore file. Therefore, I thought I should share it with you. Here it is: [shell] log/* tmp/* .DS_Store db/* [/shell] Enjoy!…
Read more ⟶

Link Bag September 05 2010


Yet another post that will gather links and useful information of intersting stuff, that will probably be useful to my readers. General Launching beta, or “How to decide when and where to cut corners– A great post from CodeBetter.com with a reference to Nate Kohari’s post on the same subject. A very good read if you are planning in launching a product anytime soon. Freelancing 10 Requirements for Working with Clients in Other Countries – I work with clients in other countries all of the time, mostly in the US and Japan.…
Read more ⟶

Maintain sort on a DataGrid when the dataProvider is changed


Usually, in our Flex application we do have a data-grid. This component is very useful for displaying data and have a sorting, ordering of columns and more, out of the box. I can speak for my applications and say that every enterprise application I have ever build had at least one or more data-Grid’s inside it. So, what can we say about a grid that has not been said before in the past…?…
Read more ⟶