Fork me on GitHub

view

    Simplify render in views

    04 Dec 2010

    Richard Huang

    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 


    Generate polymorphic url

    23 Sep 2010

    Richard Huang

    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

    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

    use OpenStruct when advance search Read More

    Tags 


    Use render :collection Rails when possible

    29 Jul 2010

    Helmut Juskewycz

    Tags 


    Replace instance variable with local variable

    24 Jul 2010

    Wen-Tien Chang

    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

    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

    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

    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

    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

    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