Posts

Showing posts from August, 2016

Drag and drop ordering in rails

Add order_number column into news table:-  rails g migration add_order_number_to_news order_number:integer In config/routes.rb     get '/news_ordering/(:id)' => 'news#news_ordering', as: :news_ordering    post  '/re_order_news'                              => 'news#re_order_news' In app/views/news/news_ordering.html.erb   <style>   #sortable {      list-style-type: none;     margin: 0;      width: 60%;     cursor: pointer;   }   .pic_box {     border: 1px #cccccc solid;      padding: 2%;     margin: 1%;      width: 50%;   }   .img_box{     height: 60px;     width: 60px;   } </style> <div class="wrapper wrapper-content animated fadeInRight">     <p id="notice"><%= notice %></p>     <div class="row">         <div class="col-lg-12">             <div class="ibox float-e-margins">    

Order items by Drag and drop in ruby on rails

Add order_number column into news table:-  rails g migration add_order_number_to_news order_number:integer In config/routes.rb    get '/news_ordering/(:id)' => 'news#news_ordering', as: :news_ordering    post  '/re_order_news'                              => 'news#re_order_news' In app/views/news/news_ordering.html.erb   <style>   #sortable {      list-style-type: none;     margin: 0;      width: 60%;     cursor: pointer;   }   .pic_box {     border: 1px #cccccc solid;      padding: 2%;     margin: 1%;      width: 50%;   }   .img_box{     height: 60px;     width: 60px;   } </style> <div class="wrapper wrapper-content animated fadeInRight">     <p id="notice"><%= notice %></p>     <div class="row">         <div class="col-lg-12">             <div class="ibox float-e-margins">      

Drag and drop ordering in rails

Add order_number column into news table:-  rails g migration add_order_number_to_news order_number:integer In config/routes.rb     get '/news_ordering/(:id)' => 'news#news_ordering', as: :news_ordering    post  '/re_order_news'                              => 'news#re_order_news' In app/views/news/news_ordering.html.erb   <style>   #sortable {      list-style-type: none;     margin: 0;      width: 60%;     cursor: pointer;   }   .pic_box {     border: 1px #cccccc solid;      padding: 2%;     margin: 1%;      width: 50%;   }   .img_box{     height: 60px;     width: 60px;   } </style> <div class="wrapper wrapper-content animated fadeInRight">     <p id="notice"><%= notice %></p>     <div class="row">         <div class="col-lg-12">             <div class="ibox float-e-margins">      

Get Fitibt Access token bu oauth2 authentication.

Get the code by setting up omniauth callback URL:- redirect_to "https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=#{ENV['FITBIT_CLIENT_ID']}&redirect_uri=#{$URL}%2Fauth%2Ffitbit_oauth2%2Fcallback%2F&scope=activity%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight&expires_in=604800" You will get code in params[:code], then use this code in following script;- uri = URI.parse("https://api.fitbit.com/oauth2/token")         http = Net::HTTP.new(uri.host, uri.port)         http.use_ssl = true         request = Net::HTTP::Post.new(uri.request_uri)         header_string =  Base64.encode64(("#{ENV['FITBIT_CLIENT_ID']}:#{ ENV['FITBIT_CONSUMER_SECRET']}"))         request.set_form_data('clientId' => ENV['FITBIT_CLIENT_ID'], 'grant_type' => 'authorization_code', 'redirect_uri' => $URL + '/auth/fitbit_oauth2/c