3 Replies Latest reply on Apr 17, 2013 9:01 AM by Mohit Raheja

    Newbie to RhoMobile and Ruby

      Please help me in understanding the exact meaning of the below statement in index.erb

      <a href="<%= url_for :controller => :Settings, :action => :do_sync %>" class="ui-btn-left" data-icon="refresh">
            Sync
          </a>
      url_for :controller => :Settings, :action => :do_sync?

      1. how it is connected to controllers and erbs??

      2. First it is redirected to erb then controller or reverse?

        • Re: Newbie to RhoMobile and Ruby
          Darryn Campbell
          1. That code calls the ruby do_sync method in your Settings Controller's controller.rb.  If you look in your application you generated from the tutorial you'll see a folder under your app root /app/Settings and in there you'll find the controller.rb with the do_sync function combined.
          2. The controller is responsible for managing communication between the model and the view, there isn't any redirection happening necessarily.

           

          I directed you to some tutorial videos in another thread which I suggest you take a look on for a clearer understanding

          I would suggest taking a look at Rob's introduction to RhoStudio:https://developer.motorolasolutions.com/docs/DOC-1637 and you can follow his slides at https://launchpad.motorolasolutions.com/appforum/presentations/rhomobile/RhoStudio-RobGalvin.pdf.  He'll walk you through creating an app which can be easier to follow than the online tutorials.

           

          Thanks.

          1 of 1 people found this helpful
          • Re: Newbie to RhoMobile and Ruby
            Kutir Mobility

            Hi Ankur

             

            Basically <%= url_for :controller => :Settings, :action => :do_sync %> is embedded ruby code in erb page. The line specifies to which controller the action should be called when user clicks the link. Executing the code will give as "app/Settings/do_sync"  When the link is clicked, it will first go to the do_sync action in Settings_controller.rb file. Depending on the code in do_sync action, it will communicate with model and show the view to the user

             

            Hope it is clear

             

            Thanks

            Dhepthi

            Kutir Mobility

            1 of 1 people found this helpful
            • Re: Newbie to RhoMobile and Ruby
              Mohit Raheja

              Hi Ankur,

               

              It is a way of giving URL in href attribute using ruby code. Here the :controller attribute defines in which controller file should a thread go and action defines which method to call. If in case the method will not be there in controller then it will look for the corresponding .erb file.

              So the flow is firstly it will go to controller then to .erb file

               

              Thanks

              Mohit raheja