blog

Best15CommonUseGem

  • 10/09/2016
  • Posted inROR

<div dir="ltr"> <div><span style="font-size:14px;">HI,</span><br /> &nbsp;</div> <span style="font-size:14px;">In your free time make an application and use all of the 15 gem in the demo app so it will be easy when working on app for client</span> <div> <div>&nbsp;</div> <div><span style="font-size:14px;">These gems are the &ldquo;core&rdquo; of each our Gemfile because they allow to solve the most common problems that face in every application. In support of these gems, there are lot of gems that allow you to develop social functions, audit templates, integration with external APIs and more.<br /> <br /> Devise (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fdevise%26urlhash%3D1832%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882619000&amp;usg=AFQjCNHKZgO11ZAA7t9gsFyiyWmPx8Cv5Q" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fdevise&amp;urlhash=1832&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/dev<wbr />ise</a>): Since some years ago, it represents the authentication mechanism preferred by all Rails developers. Powerful, flexible, allows to integrate with OAuth authentication systems with a minimal effort.<br /> <br /> Haml (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fhaml%26urlhash%3DMuw2%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882619000&amp;usg=AFQjCNHLjO3JRTop2QVbH4qg5cceL9hCPQ" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fhaml&amp;urlhash=Muw2&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/ham<wbr />l</a>): Allows you to write valid XHTML concisely. The learning curve is relatively short.<br /> <br /> Gritter (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fgritter%26urlhash%3DJnfb%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882619000&amp;usg=AFQjCNFDILf2rOE6xoAF0Rt0PYqIAiCkoQ" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fgritter&amp;urlhash=Jnfb&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/gri<wbr />tter</a>): After years of flash messages in the classic div in the page, we moved to Growl like notifications. Thanks to these pop-ups, we can show our flash messages in any page in a completely non-invasive and elegant way.<br /> <br /> Cells (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fcells%26urlhash%3Dy2Ow%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882619000&amp;usg=AFQjCNEsMSHexGcinIB4nDeLNvwE5uwxKg" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fcells&amp;urlhash=y2Ow&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/cel<wbr />ls</a>): Cells can really keep our controllers very skinny. We use it to represent and caching some boxes, like &ldquo;recommended items&rdquo;, &ldquo;top users&rdquo; and so on. I really like Cells over the use of helpers.<br /> <br /> FriendlyId (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Ffriendly_id%26urlhash%3DCKvz%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882619000&amp;usg=AFQjCNGU0XfMR7kX6f6UdbGNxlbi2rP2yQ" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Ffriendly_id&amp;urlhash=CKvz&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/fri<wbr />endly_id</a>): A perfect gem to make our url seo friendly.<br /> <br /> SimpleForm (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fsimple_form%26urlhash%3DrmM-%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882619000&amp;usg=AFQjCNGiQM8UD5qauj7ILMaoRNKAUFudaA" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fsimple_form&amp;urlhash=rmM-&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/sim<wbr />ple_form</a>): We use it primarily for its excellent integration with Bootstrap and for its ease of use.<br /> <br /> Paperclip (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fpaperclip%26urlhash%3DWkE4%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882619000&amp;usg=AFQjCNGpKC2Zgh-iFzPkGT9BcRMCc5cZYA" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fpaperclip&amp;urlhash=WkE4&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/pap<wbr />erclip</a>): Despite the years, it still remains the reference point for attachments management .<br /> <br /> Kaminari (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fkaminari%26urlhash%3D857T%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNFPt4t4n11PW88o6YaicKMVhFq79A" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fkaminari&amp;urlhash=857T&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/kam<wbr />inari</a>): Useful gem to manage paginated collections .<br /> <br /> Cancan (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fcancan%26urlhash%3DYQ9h%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNF5xvPGk513IczLplISm1_zTyg1AQ" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fcancan&amp;urlhash=YQ9h&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/can<wbr />can</a>): Our choice to manage permissions. We never have had the need to use some other solution .<br /> <br /> Resque (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fresque%26urlhash%3DSYD1%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNEiLR_DG4A2unIPQnS_pDOIbDVmng" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fresque&amp;urlhash=SYD1&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/res<wbr />que</a>) or Delayed Job (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fdelayed_job%26urlhash%3DseLk%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNF8WepuCssm94BR6-POhTC8YmdI_Q" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fdelayed_job&amp;urlhash=seLk&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/del<wbr />ayed_job</a>): Both are valuable supports to manage background processes. If you do not have enough resources to set up a Redis server, we recommend Delayed Job.<br /> <br /> Sunspot (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fsunspot%26urlhash%3DSl-M%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNFEKN_-Kq6FQ7c-94OUldmeoynJHw" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fsunspot&amp;urlhash=Sl-M&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/sun<wbr />spot</a>): After a brief period with thinking_sphinx, we have moved to this very powerful indexing engine. Thanks to Solr, we can easily implement geolocated full text searches. The only problem is that you need to configure a dedicated Tomcat server. If you do not have these resources, we recommend using pg_search (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fpg_search%26urlhash%3DBcN9%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNHms6PLQsmbGP2r-xEhSavKFU2LNg" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fpg_search&amp;urlhash=BcN9&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/pg_<wbr />search</a>) with a Postgres database or the old but still valid meta_search (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttp%253A%252F%252Frubygems%252Eorg%252Fgems%252Fmeta_search%26urlhash%3D-pU4%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNHNJhDglh6YAJTh3Rg8ynTvsqpN3Q" href="https://www.linkedin.com/redirect?url=http%3A%2F%2Frubygems%2Eorg%2Fgems%2Fmeta_search&amp;urlhash=-pU4&amp;_t=tracking_anet" rel="nofollow" target="_blank">http://rubygems.org/gems/meta<wbr />_search</a>) .<br /> <br /> ActiveAdmin (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Factiveadmin%26urlhash%3Dq8U9%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNH-dZwlJO_lUm_XFtnmAxd8_jHxrw" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Factiveadmin&amp;urlhash=q8U9&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/act<wbr />iveadmin</a>): When it is necessary to set up a back office administration in a short time, here is the right gem. Powerful, fairly customizable, ideal for simple administration interfaces.<br /> <br /> Letter opener (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fletter_opener%26urlhash%3DGw6E%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNHcezLweNAMGCAOv9T6wUB1ggUm_A" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fletter_opener&amp;urlhash=Gw6E&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/let<wbr />ter_opener</a>): Useful to test sending emails simply by opening them in a browser window .<br /> <br /> RSpec (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Frspec%26urlhash%3Dlx_q%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNHOZlXVbOINq2RacC7oJsE-arqrvQ" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Frspec&amp;urlhash=lx_q&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/rsp<wbr />ec</a>): A perfect gem to test our models in a BDD way.<br /> <br /> Capybara (<a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=https://www.linkedin.com/redirect?url%3Dhttps%253A%252F%252Frubygems%252Eorg%252Fgems%252Fcapybara%26urlhash%3DmaR9%26_t%3Dtracking_anet&amp;source=gmail&amp;ust=1471088882620000&amp;usg=AFQjCNHAlgPa18REuJ_DRVPhLhfjdBMLfQ" href="https://www.linkedin.com/redirect?url=https%3A%2F%2Frubygems%2Eorg%2Fgems%2Fcapybara&amp;urlhash=maR9&amp;_t=tracking_anet" rel="nofollow" target="_blank">https://rubygems.org/gems/cap<wbr />ybara</a>) : In addition to unit test the models, we like to create a suite of acceptance tests. Capybara allows you to test all the application&rsquo;s user stories relatively quickly.</span></div> </div> </div> <div class="yj6qo ajU"> <div aria-label="Hide expanded content" class="ajR" data-tooltip="Hide expanded content" id=":12r" role="button" tabindex="0">&nbsp;</div> </div>



Steps to run python code on windows

  • 25/08/2016
  • Posted inROR

<p><span style="font-size:14px;">Hello,</span></p> <div><span style="font-size:14px;">Steps to run django code on windows :</span></div> <div>&nbsp;</div> <div><span style="font-size:14px;">1) if python is not installed first install it and than set the path.</span></div> <div><span style="font-size:14px;">2)&nbsp;<span style="color: rgb(12, 75, 51); font-family: 'Fira Mono',Consolas,Menlo,Monaco,'Courier New',Courier,monospace; line-height: 21px; white-space: pre-wrap;">pip install virtualenvwrapper-win</span></span></div> <div><span style="font-size:14px;"><font color="#0c4b33" face="Fira Mono, Consolas, Menlo, Monaco, Courier New, Courier, monospace"><span style="line-height: 21px; white-space: pre-wrap;">3)</span></font><span style="color: rgb(12, 75, 51); font-family: 'Fira Mono',Consolas,Menlo,Monaco,'Courier New',Courier,monospace; line-height: 21px; white-space: pre-wrap;">mkvirtualenv myproject</span></span></div> <div><span style="font-size:14px;"><font color="#0c4b33" face="Fira Mono, Consolas, Menlo, Monaco, Courier New, Courier, monospace"><span style="line-height: 21px; white-space: pre-wrap;">4)</span></font><span style="color: rgb(12, 75, 51); font-family: 'Fira Mono',Consolas,Menlo,Monaco,'Courier New',Courier,monospace; line-height: 21px; white-space: pre-wrap;">workon myproject</span></span></div> <div><span style="font-size:14px;"><font color="#0c4b33" face="Fira Mono, Consolas, Menlo, Monaco, Courier New, Courier, monospace"><span style="line-height: 21px; white-space: pre-wrap;">5) cd to the folder where you manage.py file is kept.</span></font></span></div> <div><span style="font-size:14px;"><font color="#0c4b33" face="Fira Mono, Consolas, Menlo, Monaco, Courier New, Courier, monospace"><span style="line-height: 21px; white-space: pre-wrap;">6) pip install -r requirements.txt</span></font></span></div> <div><span style="font-size:14px;"><font color="#0c4b33" face="Fira Mono, Consolas, Menlo, Monaco, Courier New, Courier, monospace"><span style="line-height: 21px; white-space: pre-wrap;">7) python manage.py runserver</span></font></span></div> <div><span style="font-size:14px;"><font color="#0c4b33" face="Fira Mono, Consolas, Menlo, Monaco, Courier New, Courier, monospace"><span style="line-height: 21px; white-space: pre-wrap;">it will run the code on your local.</span></font></span></div>



Steps to Upload any type of media in ruby on rails by paperclip

  • 09/08/2016
  • Posted inROR

<div><span style="font-size:14px;">1) Upload video</span></div> <div>&nbsp;</div> <div><span style="font-size:14px;">a) apply&nbsp;<span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238);">gem </span><span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(128, 0, 0); background-color: rgb(238, 238, 238);">&quot;paperclip-ffmpeg&quot;</span><span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238);">,</span><span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238);"> </span><span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(128, 0, 0); background-color: rgb(238, 238, 238);">&quot;~&gt; 1.0.1&quot;</span></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;">b) Apply validation in model</span></div> <div> <pre style="margin-top:0px;padding:5px;border:0px;overflow:auto;width:auto;max-height:600px;word-wrap:normal"> <span style="font-size:14px;"><span style="margin: 0px; padding: 0px; border: 0px none;"><span style="margin: 0px; padding: 0px; border: 0px none;"><code><font color="#000000" face="Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif"><span style="white-space: inherit; background-color: rgb(238, 238, 238);">has_attached_file </span></font></code></span><code><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">video</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">,</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">styles </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">{:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">medium </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">{</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">geometry </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(128, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">&quot;300x300&quot;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">,</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">format </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(128, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">&#39;flv&#39;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">},:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">thumb </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">{:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">geometry </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(128, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">&quot;100x100#&quot;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">,</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">format </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(128, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">&#39;jpg&#39;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">,</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">time </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(128, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">15</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">}</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">},</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">processors </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">=&gt;</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">[:</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">ffmpeg</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);">]</span><span style="color: rgb(0, 0, 0); font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; background-color: rgb(238, 238, 238);"> </span></code></span></span></pre> </div> <div><span style="font-size:14px;">c) Install ffmpeg on your&nbsp;system</span></div> <div><span style="font-size:14px;"><span style="color: rgb(38, 38, 38); line-height: 16px;">sudo apt-add-repository ppa:jon-severinsson/ffmpeg&nbsp;</span></span></div> <div><span style="font-size:14px;"><span style="color: rgb(38, 38, 38); line-height: 16px;">sudo apt-get update&nbsp;</span></span></div> <div><span style="font-size:14px;"><span style="color: rgb(38, 38, 38); line-height: 16px;">sudo apt-get install ffmpeg</span></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;"><font color="#262626"><span style="line-height: 16px;">d) Play video by using rails video_tag</span></font></span></div> <div> <pre style="border:1px dotted rgb(159,155,99);padding:1em;overflow:auto;color:rgb(0,0,0);background-color:rgb(255,253,223)"> <span style="font-size:14px;"><span style="color: rgb(0, 0, 68);"><a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/video_tag&amp;source=gmail&amp;ust=1471089826524000&amp;usg=AFQjCNFzS4f2HG9JmDePRW57bVlp0-nzpw" href="http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/video_tag" style="color:rgb(35,63,191);text-decoration:none" target="_blank">video_tag</a></span><span style="color: rgb(68, 68, 119); font-weight: bold;">(&quot;</span><span style="color: rgb(153, 68, 68); background: none repeat scroll 0% 0% rgb(255, 255, 238);">trailer.ogg</span><span style="color: rgb(68, 68, 119); font-weight: bold;">&quot;,</span> <span style="color: rgb(0, 0, 68);">controls</span><span style="color: rgb(68, 68, 119); font-weight: bold;">:</span> <span style="color: rgb(0, 119, 255);">true</span><span style="color: rgb(68, 68, 119); font-weight: bold;">,</span> <span style="color: rgb(0, 0, 68);">autobuffer</span><span style="color: rgb(68, 68, 119); font-weight: bold;">:</span> <span style="color: rgb(0, 119, 255);">true</span><span style="color: rgb(68, 68, 119); font-weight: bold;">)</span></span></pre> </div> <div><span style="font-size:14px;"><font color="#262626"><span style="line-height: 16px;">&nbsp;or&nbsp;</span></font></span></div> <div><span style="font-size:14px;"><font color="#262626"><span style="line-height: 16px;">you can use&nbsp;</span></font></span></div> <div><span style="font-size:14px;"><span style="color: rgb(51, 51, 51); font-family: Consolas,'Liberation Mono',Menlo,Courier,monospace; line-height: 21.76px; background-color: rgba(0, 0, 0, 0.04);">gem &#39;jw_player_helper&#39;</span></span></div> <div> <pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(247,247,247)"> <span style="font-size:14px;"><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0px;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;line-height:inherit;word-wrap:normal;background:transparent">&lt;%= video_player({:file =&gt; &quot;/video/pf2011.flv&quot;, :image =&gt; &quot;/video/pf2011.jpg&quot;}) %&gt;</code> <span style="font-family: arial,sans-serif; line-height: normal; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255);">This will play video in any format then you do not need to use any encoder;</span></span> <span style="font-size:14px;">2) Upload Audio</span> <span style="font-size:14px;">a) Simply use&nbsp;<span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238);"> gem </span><span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(128, 0, 0); background-color: rgb(238, 238, 238);">&quot;paperclip&quot;</span><span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238);">,</span><span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238);"> </span><span style="font-family: Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space: inherit; margin: 0px; padding: 0px; border: 0px none; color: rgb(128, 0, 0); background-color: rgb(238, 238, 238);">&quot;~&gt; 3.0&quot;</span></span> <span style="font-size:14px;"><span style="margin: 0px; padding: 0px; border: 0px none;">b) rails g paperclip audio</span></span> <span style="font-size:14px;">c) Write in model<span style="color: rgb(51, 51, 51); font-family: Consolas,'Liberation Mono',Menlo,Courier,monospace; line-height: 1.45; background-color: rgb(247, 247, 247);">&nbsp;has_attached_file </span><span style="font-family: Consolas,'Liberation Mono',Menlo,Courier,monospace; line-height: 1.45; color: rgb(0, 134, 179);">:audio</span></span> <span style="font-size:14px;">d)Apply validation<font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height: 1.45; background-color: rgb(247, 247, 247);">&nbsp;</span></font></span></pre> </div> <div><span style="font-size:14px;"><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height: 1.45; background-color: rgb(247, 247, 247);">&nbsp;validates_attachment </span></font><span style="color: rgb(0, 134, 179); font-family: Consolas,'Liberation Mono',Menlo,Courier,monospace; line-height: 1.45; background-color: rgb(247, 247, 247);">:audio</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height: 1.45; background-color: rgb(247, 247, 247);">, </span></font><span style="color: rgb(0, 134, 179); font-family: Consolas,'Liberation Mono',Menlo,Courier,monospace; line-height: 1.45; background-color: rgb(247, 247, 247);">content_type:</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height: 1.45; background-color: rgb(247, 247, 247);"> { </span></font><span style="color: rgb(0, 134, 179); font-family: Consolas,'Liberation Mono',Menlo,Courier,monospace; line-height: 1.45; background-color: rgb(247, 247, 247);">content_type:</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height: 1.45; background-color: rgb(247, 247, 247);"> </span></font><span style="color: rgb(223, 80, 0); font-family: Consolas,'Liberation Mono',Menlo,Courier,monospace; line-height: 1.45; background-color: rgb(247, 247, 247);">&quot;media/x-wav&quot;</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace"><span style="line-height: 1.45; background-color: rgb(247, 247, 247);"> }</span></font></span></div> <p><span style="font-size:14px;">e) Play audio by using rails audio_tag</span></p> <div><span style="font-size:14px;">&lt;%=<span style="color: rgb(0, 0, 68);"><a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/audio_tag&amp;source=gmail&amp;ust=1471089826524000&amp;usg=AFQjCNHZtYTUMeh2J0lHM4Aok0JaNezueg" href="http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/audio_tag" style="color:rgb(35,63,191);text-decoration:none" target="_blank">audio_tag</a></span><span style="color: rgb(68, 68, 119); font-weight: bold;">(&quot;</span><span style="color: rgb(153, 68, 68); background: none repeat scroll 0% 0% rgb(255, 255, 238);">sound.wav</span><span style="color: rgb(68, 68, 119); font-weight: bold;">&quot;,</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 253, 223);"> </span><span style="color: rgb(0, 0, 68);">autoplay</span><span style="color: rgb(68, 68, 119); font-weight: bold;">:</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 253, 223);"> </span><span style="color: rgb(0, 119, 255);">true</span><span style="color: rgb(68, 68, 119); font-weight: bold;">,</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 253, 223);"> </span><span style="color: rgb(0, 0, 68);">controls</span><span style="color: rgb(68, 68, 119); font-weight: bold;">:</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 253, 223);"> </span><span style="color: rgb(0, 119, 255);">true</span><span style="color: rgb(68, 68, 119); font-weight: bold;">)</span>%&gt;</span></div>



Easy way to use has_and_belongs_to_many relationship with mongo and rails 4

  • 08/08/2016
  • Posted inROR

<div><span style="font-size:14px;">Hi,</span></div> <div>&nbsp;</div> <div><span style="font-size:14px;"><b>class User</b></span></div> <div><span style="font-size:14px;">&nbsp; include Mongoid::Document</span></div> <div><span style="font-size:14px;">&nbsp; field :name</span></div> <div><span style="font-size:14px;">&nbsp; <b>has_and_belongs_to_many</b> :follwoing, &nbsp;as: :admin_of, &nbsp;class_name: &quot;User&quot;</span></div> <div><span style="font-size:14px;">&nbsp; <b>has_and_belongs_to_many</b> :followers, as: :member_of, class_name: &quot;User&quot;</span></div> <div>&nbsp;</div> <div><span style="font-size:14px;"><b>end</b></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;">Create instance of user</span></div> <div><span style="font-size:14px;"><b>user=User.new(params[:user])</b></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;">Find users</span></div> <div><span style="font-size:14px;"><b>following=User.find_by(id: params[:following_id])</b></span></div> <div><span style="font-size:14px;"><b>followers=User.find_by(id: params[:followers_id])</b></span></div> <div><br /> <span style="font-size:14px;">Store the user through relationship</span></div> <div>&nbsp;</div> <div><span style="font-size:14px;"><b>user.following &lt;&lt; following</b></span></div> <div><span style="font-size:14px;"><b>user.followers &lt;&lt; followers</b></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;">Save user</span></div> <div><span style="font-size:14px;"><b>user.save</b></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;">or also we can save multiple user in join table by concate method.</span></div> <div><span style="font-size:14px;"><b>user.followings.concat [user1,user2,user3]</b></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;">Accessing user.</span></div> <div><span style="font-size:14px;"><b>(@user/current_user).following</b></span></div> <div><span style="font-size:14px;"><b>(@user/current_user).followers</b></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;"><b>For more information please see the below link..</b></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;"><a data-saferedirecturl="https://www.google.com/url?hl=en&amp;q=http://markentier.de/codecraft/2011/07/31/mongoid-multiple-many-to-many-relations/&amp;source=gmail&amp;ust=1471088882649000&amp;usg=AFQjCNHjeBvXFgSEt72f6KxGDRQZNsSSqw" href="http://markentier.de/codecraft/2011/07/31/mongoid-multiple-many-to-many-relations/" target="_blank">http://markentier.de/codecraft<wbr />/2011/07/31/mongoid-multiple-m<wbr />any-to-many-relations/</a></span></div> <div>&nbsp;</div> <div><span style="font-size:14px;"><b>Kindly provide feedback..!</b></span></div>