http://www.flaticon.com/free-icon/circular-check-button_78016
Saturday, 25 February 2017
Friday, 24 February 2017
Click edit image icon upload image using javascript
<img src="<%= asset_path( current_user.image ) %>" id="imgprvw" class="circle_img img-circle" alt="Cinque Terre" width="150" height="136" style="border: 4px solid gray;margin-left:5% !important;">
<img src="<%= asset_path('edit.png')%>" class="edit_pin" alt="Image" onclick = "$('#user-image').click();" width="40px" >
<%= form_tag '/users/edit_profile_image', id: 'image_upload', :multipart => true do %>
<%= file_field_tag :avatar,name: "avatar",:id => "user-image" ,:onchange => "showimagepreview(this)" ,:class=>"img_file hide" %></td>
<% end %>
<script>
function showimagepreview(input) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function(e) {
$('#imgprvw').attr('src', e.target.result);
}
filerdr.readAsDataURL(input.files[0]);
}
$('#image_upload').submit();
}
</script>
controller code
@user = current_user
@user.image = params[:avatar] if params[:avatar].present?
@user.save
flash[:notice] = "Profile image has been updated."
redirect_to :back
<img src="<%= asset_path('edit.png')%>" class="edit_pin" alt="Image" onclick = "$('#user-image').click();" width="40px" >
<%= form_tag '/users/edit_profile_image', id: 'image_upload', :multipart => true do %>
<%= file_field_tag :avatar,name: "avatar",:id => "user-image" ,:onchange => "showimagepreview(this)" ,:class=>"img_file hide" %></td>
<% end %>
<script>
function showimagepreview(input) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function(e) {
$('#imgprvw').attr('src', e.target.result);
}
filerdr.readAsDataURL(input.files[0]);
}
$('#image_upload').submit();
}
</script>
controller code
@user = current_user
@user.image = params[:avatar] if params[:avatar].present?
@user.save
flash[:notice] = "Profile image has been updated."
redirect_to :back
Login from Omniauth.
Step-1 Put gem into gemfile.
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem "omniauth-google-oauth2"
gem 'omniauth-twitter'
gem "omniauth-google-oauth2"
gem 'omniauth'
and after that run bundle command on your console.
Step-2 App->Config->initializer-> omniauth.rb.
copy and paste few line below given.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, '10370967297316xxx' , '6703b75235b704e789aa9fbb649xxxx'
or set environment variable
or set environment variable
provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"]
provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
end
after you will change some thing in your config file you have to restart the server again.
Step-3 you have to added migration
rails g migration AddOmniautoToUsers
open migration file copy and paste this code
add_column :users, :provider, :string
add_column :users, :uid, :string
add_column :users, :name, :string
in console type command -> rake db:migrate
step -4 user model
def self.sign_in_from_omniauth(auth)
user = where(provider: auth['provider'], uid: auth['uid']).first_or_initialize
user.email = auth['info']['email']
user.name = auth['info']['name']
user.password = Devise.friendly_token[0,20]
user.confirmed_at = Time.now
user.save
user
end
step -5 User controller
def omniauth
auth=request.env["omniauth.auth"]
session[:omniauth] = auth.except('extra')
user = User.sign_in_from_omniauth(auth)
sign_in user
redirect_to root_url, notice: "SIGNED IN"
end
Step-6 in routes.rb
get 'auth/:provider/callback', to: "users#omniauth"
Step 7 - put this is link in view
<%= link_to "/auth/facebook" do %>Facebook<% end %>
<%= link_to 'Twitter', '/auth/twitter' %>
<%= link_to 'Google+', '/auth/google' %>
Wednesday, 22 February 2017
Monday, 13 February 2017
Sublime 2 Tab space
cd ~/.config/sublime-text-3/Packages/
sudo chown development:development User -R
Here development is the username of system like root, deploy
sudo nano ~/.config/sublime-text-3/Packages/User/Preferences.sublime-settings
add below
{
"tab_size": 2
}
Subscribe to:
Posts (Atom)
Revert last commit or second last and more....
Git revert commit_id -m 1 this command willl revert last commit Git revert commit_id -m 2 this command will revert second commit with same...
-
1. step : <script type="text/javascript"> window.onload = function(){ //Check File API support if(...
-
def time[A](f: => A) = { val s = System.nanoTime val ret = f println("time: " + (System.nanoTime - s) / 1e9 + ...
-
1. Add gem "aws-sdk-s3" and bundle install require 'aws-sdk-s3' # AWS S3 bucket upload method def self.upload...