Ruby on Rails: putting class with submit_tag
Ruby on Rails: putting class with submit_tag <%= submit_tag(“Update”, :id=>”button”, :class=>”Test”, :name=>”submit”) %> First parameter is required and it would be value and they any parameter you want to specify, can be done in a hash like :key=>”value”.
ADDING IMAGES IN RUBY html( .ERB) FILE
HTML .ERB FILE (adding image using tags) First of all we have to know the syntax of adding images in html file which is <img src=”image.jpg”/> Now using this syntax will not give us image in output To use this image first of all create a folder ( public )where app file (app.rb) is present…
RAILS adding image through .scss file
RAILS adding image through home.scss file or any .scss file For working on .scss file we have to take care of how to add an image though this file. So first of all we have to use simple background-image tag background-image: url(‘your image url’); now add these lines , -webkit-background-size: cover; -moz-background-size: cover; -o-background-size:…
Append in rails[AJAX][info]
Append in rails THESE both line ; the line 3 and 9 meant same. You can use either of them. These lines are used when you want to append html pages using ajax.
MAKING FOLLOW-MAPPING ON RAILS
MAKING FOLLOW-MAPPING ON RAILS STEP-1: On terminal $rails g model FollowMapping follower_id:integer followee_id:integer $rake db:migrate STEP-2: home_controller def users @users = User.all end STEP-3: In home folder, create a file users.html.erb <%= user.email %> <% if current_user.can_follow user.id %> <%= link_to “Follow”, url_for(controller: :home, action: :follow, followee_id: user.id), method: :post %> <% end %>…
Readmorejs::Rails (HOW TO?)
Readmorejs::Rails Installation Add this line to your application’s Gemfile: gem ‘readmorejs-rails’ And then execute: $ bundle install Or install it yourself through terminal: $ gem install readmorejs-rails How to use? In your application.js, include the js file: //= require readmore Now directly use in your any html.erb file , like this and now write a…
Deploy Rails to Heroku
Deploy Rails to Heroku Follow these 12 steps for deploying your app on heroku. Create a new Heroku account. In the terminal, log in using the email address and password of Heroku account: $ heroku login In Gemfile, add the pg gem to your Rails project. Change: gem sqlite to gem ‘sqlite3’, group: :development gem ‘pg’,…
Create unique id in link_to tag rails
Create unique id in link_to tag rails <%= link_to “Edit”, edit_question_path(question.id),method: :get, :remote => true, id: “myBtn_#{question.id}” %> This is how you can create a unique id using #. id: “myBtn_#{question.id}”
Adding time at which tweet or any text created in rails
Adding time at which tweet or any text created in rails So, for adding time use the above code if tweet or text was added before 24 hours then it will display as 2 hours ago or 4 hours ago and if more than a day time then it will display date. <% if…
Changing the name of already made Heroku app??
Changing the name of already made Heroku app?? Step 1: This step will create an app with some arbitrary name $ heroku create Step 2: This step will show the url of the remote servers that you have config. $ git remote -v Step 3: In this step go to your app on heroku and rename it…
Get new content delivered directly to your inbox.
Leave a comment