Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

basic-initial-rails4

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-initial-rails4

  • 1.1.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Basic::Initial::Rails4

TODO: Write a gem description

Installation

Add this line to your application's Gemfile:

gem 'basic-initial-rails4'

Add permited omniauth gem in you Gemfile:

gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem 'omniauth-linkedin'
gem 'omniauth-github'

You can view documentation for each omniauth gem in:

  • omniauth-facebook
  • omniauth-twitter
  • omniauth-linkedin
  • omniauth-github

And then execute:

$ bundle

Or install it yourself as:

$ gem install basic-initial-rails4

Usage

execute:

$ rails generate model user name email password_digest id_facebook id_twitter id_linkedin id_github
$ rails generate binstall

This proccess write and create an important methods and files

  • config/initializers/mail.rb
    ActionMailer::Base.smtp_settings = {
           user_name: 'example@example.com', #use the smtp user account
           password: 'example',              #put a password
           address: 'smtp_settings',         #use a smtp url smtp.gmail.com, smtp.live.com, etc.
           port: 587,                        #use a port to smtp settings
           enable_starttls: true             #use a tls (Transport Layer Security)
    }

Transport Layer Security

    class Notifier < ActionMailer::Base
      from_address = ActionMailer::Base.smtp_settings[:user_name]
      default from: "App Name <#{from_address}"

      def mail_method(mail)
        subject = "#{mail.subject} from App name"
        mail(to: mail.email, subject: subject)
      end
    end
  • config/environments/development.rb
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.perform_deliveries = true

This file have a:

    config.action_mailer.raise_delivery_errors = false

Change to true

    config.action_mailer.raise_delivery_errors = true
  • app/notifier/mail_method.html.rb

    Empty file represent the theme for mail send

  • app/controllers/application_controller.rb

    before_filter :load_initial
    def load_initial
      @init_twitter = nil  #change nil to anithing valor to view = link_to 'Twitter', '/auth/twitter'
      @init_github = nil   #this load a = link_to 'Github', '/auth/github'
      @init_facebook = nil #this load a = link_to 'Facebook', '/auth/facebook'
      @init_linkedin = nil #this load a = link_to 'Linked_in', '/auth/linked_in'
    end

    def is_login!
      if session[:user_id].nil?
        redirect_to sessions_new_path, notice: 'You need login to load this section'
      elsif $current_user.nil?
        $current_user = User.find_by_id(session[:user_id])
      end
    end
  • config/routes.rb
    get 'sessions/new'
    post 'sessions/new', to: 'sessions#create'
    get 'sessions/destroy', to: 'sessions#logout'
    resources :users, only: [:index, :create, :new]
    get '/auth/:provider/callback', to: 'sessions#create'
    get '/auth/failure', to: 'sessions#failure'
  • app/models/user.rb
    has_secure_password
    validates :name, presence: true, uniqueness: true, length: { minimum: 5, maximum: 18}, format: {with: /[a-zA-Z\s]/}
    validates :password, presence: true, length: { minimum: 8, maximum: 24}
    validates :email, presence: true, uniqueness: true, format: {with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }

Notes of usage

Your need a root to in routes.rb file

    root to: 'controller_name#method_name'

spec notes

So test a controller with is_login! before_filter you need include

    session[:user_id] = user.id  #where user is a instance of User model (factory)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 15 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc