Total Blog Views: 44
Blog Status: publish
Created By: swazahmad Created at: 08-08-2021
Tags: ruby on rails rails 07 star-rating
As In the current Technology world Every one wants the dynamic feature in there website in day to dy use
So We will learn today
We Will Create a Sample App For the same
$ rails new StarRateApp
$ rails g scaffold Blog title:string body:text
Note: The above command will create All the files required For Blog Module(Model View Controller), Then Run Below Command
$ rails db:create db:migrate
Rails.application.routes.draw do
resources :blogs
root 'blogs#index'
end
Now The sample Application is ready Now You can Run $ rails s and check your application then add some sample Items
gem 'ratyrate'
gem 'devise' #If not present
After Adding the Gem Run Bundle Install
$ bundle install
Then We need to configure the User module
$ rails g ratyrate user
We are Considering you will have a devise user model which name is User. The devise generator and ratyrate generator should be like below Note: If devise is not configured then run below 2 commands
$ rails g devise:install
$ rails g devise user
$ rails g ratyrate user # => user is the model generated by devise
//= require jquery.raty
//= require ratyrate
class User.rb < ApplicationRecord
ratyrate_rater
end
class Blog < ApplicationRecord
ratyrate_rateable "blog_content", "presentation", "blogger"
end
<p>
Blog Content : <%= rating_for @blog, 'blog_content', disable_after_rate: true %>
Presentation : <%= rating_for @blog, 'presentation', disable_after_rate: true %>
Blogger(User added Blog) : <%= rating_for @blog, 'blogger', disable_after_rate: true %>
</p>
$ rails s
Note: You can ask any question in comment
The Below start is the exact example of rating of above Blog
we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.
© Copyright Shadbox. All Rights Reserved
Rate Blog :
Share on :
Do you have any blog suggestion? please click on the link