Posts

Rails Tricks

Image
1.  What is request.xhr ? Ans: A request.xhr tells the controller that the new  Ajax  request has come, It always return Boolean    values (TRUE or FALSE) 2.  What is MVC? and how it Works?   Ans:  MVC tends for Model-View-Controller, used by many languages like PHP, Perl, Python etc. The flow goes like this: Request first comes to the controller, controller finds and appropriate view and interacts with model, model interacts with your database and send the response to controller then controller based on the response give the output parameter to view, for Example your url is something like this:  http://localhost:3000/users/new  here users is your controller and new is your method, there must be a file in your views/users folder named new.html.erb, so once the submit button is pressed, User model or whatever defined in the rhtml form_for syntax, will be called and values will be stored into the database. 3 . What things we can define in the model?   Ans: There are lot of
In order to upload multiple file to the server the basic thing what we require is multiple file fields. we can do it easily in .erb file with the help of javascript. So just follow the steps and have fun. Step 1 :  create a simple html div for it.                 <div class="apply_div  " id="number_of_download_filed" >        <div class="attachment_div_text" id='div_attached_1'>Add Attachment,</div> <div class="attachment_div_field" id="div_attached_field_1"> <input id='attached_1' type='file' name='attached_1' class='event_action_attach_fields input_file_class'> </div>             </div>            <div class="apply_div ">                              <%= button_tag ' Attach another file ',  :type => 'button',  : class="attach_another_file_button"   %>             </div>

Video chat in rails 3

Video streeming is always a challenge for the rails programmer. I am sure After reading this article  every one CAN DO IT EASILY.  :) Gems used:       gem 'raydash', '2.1.0'       gem 'jquery-rails' Step 1 :       First generate a new rails project by typing rails new Demo_apps. Step 2:    Inside Your gem file add the raydash gem. You can check the version from rubygems.org. Step 3:    Go to http://www.raydash.com/ and generate Your user_id, and secret. Step 4:    Configure Demo_apps with your user_id and secret with the command:     rails g raydash:install [userid] [secret]       or you can directly go to config/initilizer and create a raydash.rb file                       and add your credentials there.     Step 5:            Create an suitable controller and add this       @token = Raydash.getToken()           Step 6:          for the view page write this