You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rails new PROJECT_NAME
cd PROJECT_NAME
# test if server is working
rails s
Fixing sqlite version
#<LoadError: Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile.>
rails routes
Prefix Verb URI Pattern Controller#Action
root GET / courses#index
courses_new GET /courses/new(.:format) courses#new
about GET /about(.:format) pages#about
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
<divclass="container"><divclass="row center sign-up-form"><divclass="col s12 m12 l12"><divclass="card-panel"><h3class="header">Sign up !</h3><divclass="row"><%=form_for(@student,html: {class: "col s12"})do |f| %><divclass="row"><divclass="input-field col s12"><%=f.text_field:name,placeholder: "Enter your full name",autofocus: true%><%=f.label:name%></div></div><divclass="row"><divclass="input-field col s12"><%=f.text_field:email,placeholder: "Enter your email address"%><%=f.label:email%></div></div><divclass="row"><divclass="input-field col s12"><%=f.submit"Sign up",class: "btn orange waves-effect waves-light right"%></div></div><%end%></div></div></div></div></div>
create action
defcreate@student=Student.new(student_params)if@student.saveflash[:success]="You have successfully signed up"redirect_toroot_pathelserender'new'endendprivatedefstudent_paramsparams.require(:student).permit(:name,:email)end
flash messages
fade out flash message with jquery
$('#fade-out-target').fadeOut(4000);
add a flash message
flash[:notice]="You have successfully signed up"
remove default behaviour of errors on forms' input
# Add to config/environment.rbActionView::Base.field_error_proc=Proc.newdo |html_tag,instance_tag|
html_tagend
Go through all forms errors
<% if @student.errors.any? %><divclass="container"><divclass="row sign-up-form"><divclass="col s12 m12 l12"><divclass="card-panel red lighten-1"><spanclass="white-text"><strong><%=pluralize(@student.errors.count,"error")%>
prohibited your profile from being created: </strong><ul><%@student.errors.full_messages.eachdo |message| %><li><%=message%></li><%end%></ul></span></div></div></div></div><%end%>
Go through all flash messages
<% flash.each do |key, message| %><divclass="container"><divclass="row sign-up-form"><divclass="col s12 m12 l12"><divclass="card-panel green lighten-1" id="fade-out-target"><spanclass="white-text"><%=message%></span></div></div></div></div><%end%>
<% if obj.errors.any? %><divclass="container"><divclass="row sign-up-form"><divclass="col s12 m12 l12"><divclass="card-panel red lighten-1"><spanclass="white-text"><strong><%=pluralize(obj.errors.count,"error")%>
prohibited your profile from being <%=obj.new_record? ? "created" : "updated"%>: </strong><ul><%obj.errors.full_messages.eachdo |message| %><li><%=message%></li><%end%></ul></span></div></div></div></div><%end%>