Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
markuslopez
371 PointsA couple questions about CSS and Rails FORMS! + bootstrap
Hi,
My first question is:
How can I change the body background color of specific pages? For example, I want my login page to be blue. But just that page. Not every page.
My second question is about:
Rails forms and Bootstrap.
I have this code for my form (see below), but where do I put the rails tags in? Been having a headache about this.
<form class="form-horizontal">
<fieldset>
<!-- Form Name -->
<legend>Form Name</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">Text Input</label>
<div class="col-md-4">
<input id="textinput" name="textinput" type="text" placeholder="placeholder" class="form-control input-md">
<span class="help-block">help</span>
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-4 control-label" for="textarea">Text Area</label>
<div class="col-md-4">
<textarea class="form-control" id="textarea" name="textarea">default text</textarea>
</div>
</div>
</fieldset>
</form>
1 Answer
Sebastian Paiva
Full Stack JavaScript Techdegree Student 9,076 PointsAn option its to use differents layouts, you can select a layout by passing it through the render option in your controller
def action
render layout: "layoutname"
end
or defining a layout for the entire controller
class ProductsController < ApplicationController
layout "inventory"
#...
end
Here is more info about layouts.
An other way is to use content_for and setting the color using style with the body tag (not sure if its okey i hope someone can correct me)
<body style="background-color: <%=content_for(:body_color)? || 'blue'%>">
<!--content-->
</body>
and in your view you can set the color
content_for :body_color, 'red`'
For the forms if youre not an expert i recommend using simple_form gem with the bootstrap option, its super simple
markuslopez
371 Pointsmarkuslopez
371 Pointshey thanks for the response, i have a follow up question. for the first option you posted, can you pass a controller on a single page of a controller. for example, i want to change just my login page color, not all devise pages. how would i specifically do that? thanks again