Panayotis Matsinopoulos

...Senior Software Engineer & Project Manager

  • Increase font size
  • Default font size
  • Decrease font size
Welcome to My Personal Web Site

ezMTA

E-mail Print PDF

ezMTA - Easy Material Transfer Agreements

Read about my latest project here: http://pmatsinopoulos.github.com/projects/ezmta/

Jan 2nd, 2013

 

Last Updated on Wednesday, 02 January 2013 10:26
 

Executing Migration Commands from Rails Console

E-mail Print PDF

Did you know that you can execute migration commands from rails console? Assume that you want to change the column 'name' of the 'Product' model, to have a limit of 32 characters and set it to not null. Here is what you can do:

$ rails c
> ActiveRecord::Migration.change_column :products, :name, :string, :limit => 32, :null => false
-- change_column(:products, :name, :string, {:limit=>32})
(38.1ms)  ALTER TABLE `products` CHANGE `name` `name` varchar(32) NOT NULL
-> 0.0396s
=> nil

 

Panayotis

 

 

Last Updated on Tuesday, 25 September 2012 20:49
 

Asserting Template and Layout

E-mail Print PDF

Testing - Asserting Template and Layout

I consider testing one of the most important phase in application development and Rails does a very good job on that. However, testing documentation on Rails Guides is still work under development.

Here is a short tutorial on how you can test that a reponse has rendered the correct template and the correct layout.

If you want to make sure that the response rendered the correct template and layout, you can use the assert_template method:

test “index should render correct template and layout” do
  get :index
  assert_template :index
  assert_template :layout => “layouts/application”
end

Note that you cannot test for template and layout at the same time, with one call to assert_template method. Also, for the layout test, you can give a regular expression instead of a string, but using the string, makes things clearer. On the other hand, you have to include the “layouts” directory name even if you save your layout file in this standard layout directory. Hence,

assert_template :layout => “application”

will not work.

Gotcha: Watch out if your view renders any partial

If your view renders any partial, when asserting for the layout, you have to assert for the partial at the same time. Otherwise, assertion will fail.

Hence:

test “new should render correct layout” do
  get :new
  assert_template :layout => “layouts/application”, :partial => “_form”
end

is the correct way to assert for the layout when the view renders a partial with name _form. Omitting the :partial key in your assert_template call will complain.

Yesterday, March 24th, I tried to commit the above as my first improvement on Rails Guides, testing guide. Let us see whether this will make it through.

Panayotis

 

Capistrano - Shared directories among releases

E-mail Print PDF

Capistrano - Shared directories among releases

Capistrano is a great tool for deploying Ruby on Rails applications on remote server machines. If you have ever used it, you may already know that it creates new directory structures for each new release that it realizes and sets "current" to point to the latest one.

This is very fine, but there are cases in your application that you might want to share the same directory data among releases. You can declare in your "deploy.rb" file the directories that will be shared among your releases. By default, the directories "log", "public/system" and "tmp/pids" are already shared. Hence, you do not have to do anything for them. But, if, for example, you want to share the "my_custom_data" directory that you have inside your application structure, you need to add the following line inside your "deploy.rb" file:

set :shared_children, fetch(:shared_children) + ["my_custom_data"]

This will create a link to "shared/my_custom_data" folder by executing the following command automatically:

ln   -s  /home/<my_app>/<deployment_dir>/shared/my_custom_data   /home/<my_app>/<deployment_dir>/current/my_custom_data

Please, note that "my_custom_data" should pre-exist while you are doing the deployment. But, "bundle exec cap setup" will create shared folders anyway for you the first time you setup your servers.

Panayotis

 

Last Updated on Sunday, 02 September 2012 12:50
 

QlikView Developer II - Day II

E-mail Print PDF

 

QlikView Developer II - Day II

[My sponsor on this training is Fraudpointer S.A.]

On, March 6th, 2012, I followed the 2nd day of the QlikView Developer II training course. (Read about Day I here).

Day II was even more interesting. What I have underlined as most important to my mind were the following:

  1. We continued with SET ANALYSIS from Day I. SET ANALYSIS is extremely useful if you want to easily do comparisons.
  2. Dollar Sign Expansions. They are definitions of text replacements used in the script or in expressions.
  3. AGGR function. This is a powerful QlikView function that can be used to group by results.
  4. Talked about scripting and data modeling optimization.
  5. QlikView security.
  6. Next part of day was consumed to execute advanced scripting exercises.
Everything was very interesting and I believe that training was really worth the money.
Panayotis

 

Last Updated on Saturday, 24 March 2012 09:19
 
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  Next 
  •  End 
  • »


Page 1 of 2

Main Menu


Who's Online

We have 1 guest online