GithubHelp home page GithubHelp logo

avatar's Introduction

alt text

If there is no usermodel yet, user logic

#Gemfile
gem "devise"
$ rails generate devise:install
$ rails generate devise User
$ rails g migration AddNameToUsers name:string

$ rake db:migrate
#app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    added_attrs = %i[name]
    devise_parameter_sanitizer.permit(:sign_up, keys: added_attrs)
  end

end
$ rails generate controller Users

The meaning of the repository, replacing the gem

#app/controllers/users_controller.rb

class UsersController < ApplicationController
  before_action :set_user, only: :show

  def show
    # @letters = @user.name.upcase[0..1]
    @letters = @user.name.split.map(&:chr).join.upcase[0..1]
  end

  private

  def set_user
    @user = User.find_by name: params[:name]
  end

end
#app/views/users/show.html.erb

<div style="text-align: center;">

  <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="50" fill="#9090FF"/>
<text fill="#fff" font-family="Helvetica,Arial,sans-serif" font-size="36" font-weight="500" x="50%" y="55%" dominant-baseline="middle" text-anchor="middle">
<%= @letters %>
  </text>
</svg>

  <%= @user.name %>

</div>

avatar's People

Contributors

antnbaranov avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.