Ruby On Rails Classroom
Neha Jaggi /
Professional /
Web Technology
- Foreword to the First Edition
- Acknowledgments
- About the Author
- From Zero to Deploy
- Development Environments
- Ruby RubyGems Rails and Git
- The First Application
- rails server
- Model-view-controller MVC
- Version Control with Git
- What Good Does Git Do You
- GitHub
- Branch Edit Commit Merge
- Deploying
- Heroku Setup
- Conclusion
- A Demo App
- Planning the Application
- Modeling Demo Users
- Modeling Demo Microposts
- The Users Resource
- A User Tour
- MVC in Action
- Weaknesses of this Users Resource
- The Microposts Resource
- A Micropost Microtour
- Putting the micro in Microposts
- A User has many Microposts
- Inheritance Hierarchies
- Deploying the Demo App
- Conclusion
- Static Page
- Mostly Static Pages
- Truly Static Pages
- Static Pages with Rails
- Our First Tests
- Test-driven Development
- Adding a Page
- Testing a Title Change
- Passing Title Tests
- Embedded Ruby
- Eliminating Duplication with Layouts
- Conclusion
- Advanced Setup
- Eliminating bundle exec
- Automated Tests with Guard
- Speeding up Tests with Spork
- Tests inside Sublime Text
- Rails-Flavored Ruby
- Strings and Methods
- Objects and Message Passing
- Method Definitions
- Other Data Structures
- Blocks
- Hashes and Symbols
- CSS revisited
- Ruby Classes-Constructors
- Class Inheritance
- Modifying Built-in Classes -A Controller Class
- A User Class
- Conclusion-Exercises
- Adding Some Structure
- Site Navigation
- Bootstrap and Custom CSS
- Partials
- Sass and the Asset Pipeline
- Syntactically Awesome Stylesheets
- Layout Links
- Route Tests
- Rails Routes
- Named Routes
- Pretty RSpec
- User Signup A First Step
- Signup URI
- Conclusion-Exercises
- Modeling Users
- User Model
- Database Migrations
- The Model File
- Creating User Objects
- Finding User Objects
- Updating User Objects
- User Validations
- Validating Presence
- Length Validation-Format Validation
- Uniqueness Validation
- Adding a Secure Password
- An Encrypted Password
- Password and Confirmation
- User Authentication
- User Has Secure Password
- Creating a User
- Conclusion-Exercises
- Showing Users
- Debug and Rails Environments
- A Users Resource
- Testing the User Show Page with Factories
- A Gravatar Image and a Sidebar
- Signup Form
- Tests for User Signup
- Using form for
- The Form HTML
- Signup Failure
- Signup Error Messages
- The Finished Signup Form
- The Flash
- Deploying to Production with SSL
- Conclusion-Exercises
- Sessions and Signin Failure
- Sessions Controller
- Signin Tests
- Signin Form
- Reviewing Form Submission
- Rendering with a Flash Message
- Signin Success
- Remember Me
- A Working sign in Method
- Current User
- Changing the Layout Links
- Signin upon Signup
- Signing Out
- Introduction to Cucumber Optional
- Installation and Setup
- Features and Steps
- Counterpoint RSpec Custom Matchers
- Conclusion-Exercises
- Updating Users
- Edit Form
- Unsuccessful Edits
- Successful Edits
- Authorization
- Requiring Signed-in Users
- Requiring the Right User
- Friendly Forwarding
- Showing All Users
- User Index
- Sample Users
- Pagination
- Partial Refactoring
- Deleting Users-Administrative Users
- The destroy Action
- Conclusion-Exercises
- A Micropost Model
- The Basic Model
- Accessible Attributes and the First Validation
- User Micropost Associations
- Micropost Refinements
- Content Validations
- Showing Microposts
- Augmenting the User Show Page
- Sample Microposts
- Manipulating Microposts
- Access Control
- Creating Microposts
- A Proto-feed
- Destroying Microposts
- Conclusion-Exercises
- Following Users
- The Relationship Model
- A Problem with the Data Model and a Solution
- User Relationship Associations
- Validations
- Followed users
- Followers
- Sample Following Data
- Stats and a Follow Form
- Following and Followers Pages
- A Working Follow Button the Standard Way
- A Working Follow Button with Ajax
- Making the output of find readable in shell
- CRUD Operation-Create
- The Status Feed
- Motivation and Strategy
- A First Feed Implementation
- Subselects
- The New Status Feed
- Conclusion
- Exercises
Ruby On Rails Lesson
Bootstrap and Custom CSS
In Section 5.1.1, we associated many of the HTML elements with CSS classes, which gives us considerable flexibility in constructing a layout based on CSS. As noted in Section 5.1.1, many of these classes are specific to Bootstrap, a framework from Twitter that makes it easy to add nice web design and user interface elements to an HTML5 application. In this section, we’ll combine Bootstrap with some custom CSS rules to start adding some style to the sample application.
Our first step is to add Bootstrap, which in Rails applications can be accomplished with the bootstrap-sass gem, as shown in Listing 5.3. The Bootstrap framework natively uses the LESS CSS language for making dynamic stylesheets, but the Rails asset pipeline supports the (very similar) Sass language by default (Section 5.2), so bootstrap-sass converts LESS to Sass and makes all the necessary Bootstrap files available to the current application.5
To install Bootstrap, we run bundle install as usual:
Then restart the web server to incorporate the changes into the development application. The first step in adding custom CSS to our application is to create a file to contain it:
(Use you text editor or IDE to create the new file.) Here both the directory name and filename are important. The directory
is part of the asset pipeline (Section 5.2), and any stylesheets in this directory will automatically be included as part of the application.css file included in the site layout. Furthermore, the filename custom.css.scss includes the .css extension, which indicates a CSS file, and the .scss extension, which indicates a ‘‘Sassy CSS’’ file and arranges for the asset pipeline to process the file using Sass. (We won’t be using Sass until Section 5.2.2, but it’s needed now for the bootstrap-sass gem to work its magic.)
After creating the file for custom CSS, we can use the @import function to include Bootstrap, as shown in Listing 5.4.
Listing 5.4 Adding Bootstrap CSS.
app/assets/stylesheets/custom.css.scss
This one line includes the entire Bootstrap CSS framework, with the result shown in in Figure 5.3. The placement of the text isn’t good and the logo doesn’t have any style, but the colors and signup button look promising.
Next we’ll add some CSS that will be used site-wide for styling the layout and each individual page, as shown in Listing 5.5. There are quite a few rules in Listing 5.5; to get a sense of what a CSS rule does, it’s often helpful to comment it out using CSS comments, i.e., by putting it inside /* ... */, and seeing what changes. The result of the CSS in Listing 5.5 is shown in Figure 5.4.
Listing 5.5 Adding CSS for some universal styling applying to all pages.
app/assets/stylesheets/custom.css.scss
Neha Jaggi
Skills Ruby On Rails
Qualifications :- High School - , College/University - Graphic Era Hill University, Dehradun, College/University - ,Location :-Dehradun,Dehradun,UTTARAKHAND,India
Description:-
Experienced Software Developer with a demonstrated history of working in the Information Technology and services industry. Skilled in Web Technologies (Ruby on Rails, PostgreSQL, php, Laravel and AJAX).
Explore