Fork me on GitHub

view

    Use cells to abstract view widgets

    06 Nov 2011

    Richard Huang (flyerhzm@gmail.com)

    Rails developers always pay more attentions on models and controllers refactoring, they don't take care about views modularization, that makes view codes most difficult to maintain. Here I recommend you to use cells gem to write more reuseable, testable and cacheable view codes. Read More

    Tags 


    Simplify render in views

    04 Dec 2010

    Richard Huang (flyerhzm@gmail.com)

    render is one of the often used view helpers, we can pass object, collection or local variables. From rails 2.3, more simplified syntax for render are provided. Read More

    Tags 


    Substituting before_filter :load_object

    12 Oct 2010

    (mail@dennisbloete.de)

    Instead of loading an object with a before_filter you can use a more intelligent helper_method to get the main object for the controller context. Read More

    Tags 


    Generate polymorphic url

    23 Sep 2010

    Richard Huang (flyerhzm@gmail.com)

    If you want to generate different urls according to different objects, you should use the polymorphic_path/polymorphic_url to simplify the url generation. Read More

    Tags 


    Put scripts at the bottom

    30 Aug 2010

    Richard Huang (flyerhzm@gmail.com)

    Do you experience that your website renders slow due to loading a lot of javascripts, especially loading some third-party javascripts? Move script tags to the bottom of body can speed up the render of your website. Read More

    Tags 


    use OpenStruct when advance search

    25 Aug 2010

    Alvin Ye (alvin.ye.cn@gmail.com)

    use OpenStruct when advance search Read More

    Tags 


    abuse content_for

    30 Jul 2010

    Jim Ruther Nill (jvnill@gmail.com)

    Use content_for for grouping html contents like javascript and css Read More

    Tags 


    Use render :collection Rails 3 when possible

    29 Jul 2010

    Helmut Juskewycz (hjuskewycz@hemju.com)

    Tags 


    Replace instance variable with local variable

    24 Jul 2010

    Wen-Tien Chang (ihower@gmail.com)

    In partial view, we can use the instance variable directly, but it may be confused and make it hard to reuse anywhere, because we don't know exactly which instance variable can be used, so use the local variable in partial with explicitly assignment. Read More

    Tags 


    Move code into model

    24 Jul 2010

    Wen-Tien Chang (ihower@gmail.com)

    According to MVC architecture, there should not be logic codes in view, in this practice, I will introduce you to move codes into model. Read More

    Tags 


    Move code into helper

    24 Jul 2010

    Wen-Tien Chang (ihower@gmail.com)

    According to MVC architecture, there should not be logic codes in view, in this practice, I will introduce you to move codes into helper. Read More

    Tags 


    Move code into controller

    24 Jul 2010

    Wen-Tien Chang (ihower@gmail.com)

    According to MVC architecture, there should not be logic codes in view, in this practice, I will introduce you to move codes into controller. Read More

    Tags 


    Nested Model Forms

    22 Jul 2010

    Wen-Tien Chang (ihower@gmail.com)

    Use accepts_nested_attributes_for to make nested model forms much easier, this feature is provided by rails 2.3 Read More

    Tags 


    model.collection_model_ids (many-to-many)

    22 Jul 2010

    Wen-Tien Chang (ihower@gmail.com)

    When you want to associate a model to many association models by checkbox on view, you should take advantage of model.collection_model_ids to reduce the code in controller. Read More

    Tags