I'm creating a website called NoteIt (using HAML), where users can create notes, and only view the notes they've created. How do you select a link_to part to style it?
Here is my application.html.haml file:
!!!
%html
%head
%title NoteIt | Your online Notebook
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
%body
%header
.header_inner
%h3 NoteIt << Here is where the NoteIt sign is placed
%nav
-if model_signed_in?
= link_to "New Note", new_note_path
= link_to "Sign Out", destroy_model_session_path, method: :delete
- else
= link_to "Log In", new_model_session_path
%p.notice= notice
%p.alert= alert
= yield
I solved it. All you need to do is change the margin-top and margin-bottom, and set it to the desired amount of px. For the logo, I wrote NoteIt with an h1 tag.
Related
I created a rails app, added a top menu bar with position fixed. It works fine in development but when I deploy it online, I can't see my menu bar. Also I added glyph icons using FontAwesome but it doesn't show that either.
My production.rb
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.serve_static_assets = true
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
config.assets.compile = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
My application.html.haml
!!!
%html
%head
%title Blogger
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
%link{:rel => "stylesheet", :href => "http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css"}
%link{:rel => "stylesheet", :href => "http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"}
= csrf_meta_tags
%body
%header
.wrapper.clearfix
#logo= link_to "Blogger", root_path
%nav
- if user_signed_in?
= link_to current_user.name, edit_user_registration_path
= link_to "Logout", destroy_user_session_path, :method => :delete
= link_to "Add New Post", new_post_path, class: "button"
- else
= link_to "Sign in", new_user_session_path
= link_to "Sign Up", new_user_registration_path
= link_to t('Contact'), new_contact_path
%p.notice= notice
%p.alert= alert
= yield
To be specific, it doesn't load anything under the %header
I'm just starting to learn ROR and currently make my own first app - ToDo list. I almoust finished it, it worked fine, BUT I wanted to improve the look by changing the CSS. I do not know the reason, but now when I click "New task" modal window opens with an error on the whole page and it is inactive. See screenshot. Experimental way I removed all the changes in the css, but the problem is not solved.
There css settings for modal window:
.modal form {
margin-bottom: 10;
}
span.error {
color: red;
margin-left: 5px;
}
And this is html.haml for it:
.modal-header
%h2
= task.new_record? ? 'New Task' : "Edit task #{task.title}"
= simple_form_for #task, class: 'clearfix', remote: true do |f|
.modal-body
= f.input :title
= f.input :note
= f.input :completed, as: :string, input_html: { class: 'datepicker', value: task.completed.present? ? localize(task.completed, format: '%d/%m/%Y') : nil }
.modal-footer
= f.submit 'Save', class: 'btn btn-primary'
If need to send some other code that I can do it. I would be grateful for any help!
ADDED: There is html.haml of layout where is button of modal:
!!!
%html
%head
%title ToDo
= stylesheet_link_tag "application", media: "all"
= javascript_include_tag "application"
= csrf_meta_tags
%body
#header/
%h1 ToDo
%p time management application
.text-center
= link_to 'New task', new_task_path, class: 'btn btn-primary', remote: true
.text-right
%strong= current_user.email
.text-right
= link_to 'logout', destroy_user_session_path, method: :delete
= yield
ADDED2. Yes, the modal is triggered via javascript. There is code:
m = $('#modal');
m.html('<%= j(render partial: 'task_form', locals: {task: #task}) %>');
m.modal('show');
$('#modal').integrateDatepicker();
And I do not quite understand - html.haml code for modal posted above ... (start from .modal-header)
I tried to check all potential pages through bootlint, but no error is found.
I followed the source code form the rails3-devise-bootstrap-example to get my devise-login-page (that normally - without AJAX - works fine) in a popup window.
When I click on the login link nothing happens. The logfile tells me
Started GET "/facebox/fb_login" for 127.0.0.1 at 2014-01-09 19:15:0
Processing by FaceboxController#fb_login as JS
Rendered devise/shared/_links.erb (3.0ms)
Rendered devise/sessions/_new.html.erb (1155.0ms)
Rendered facebox/fb_login.js.erb (1251.0ms)
Completed 200 OK in 1509ms (Views: 1508.0ms | ActiveRecord: 0.0ms)
But no login-pop-up-window appears.
Here is the login link in my index.html.erb file
<%= link_to 'Login', fb_login_path, :remote => true %>
That starts my fb_login.js file
$.facebox('<%= escape_javascript(render :partial => 'devise/sessions/new') %>')
and should open _new.html.erb that looks like this:
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div class="form-inputs">
<%= f.input :email, :required => false, :autofocus => true %>
<%= f.input :password, :required => false %>
<%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
</div>
<div class="form-actions">
<%= f.button :submit, "Sign in" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
but it doesn't. What went wrong?
I got the answer by myself . Under assets/javascripts I had to define
jQuery ->
$('a[rel*=facebox]').facebox()
# facebox - make modal
$(document).bind "loading.facebox", ->
$(document).unbind "keydown.facebox"
$("#facebox_overlay").unbind "click"
in a js.coffee file.
Anyone know if you can assign a tag and class to the disabled or current link? The example below only displays as plain text in the browser for the current link.
I have a bit of rails code displaying a list of buttons for each design in the database.
<% #id_cards.each do |id| %>
<%= link_to_unless_current id.design_type, id_card_design_path(id.id), :class => 'btn' %>
<% end %>
The active links are assigned the correct class and display as buttons.
link_to_unless_current accepts a block which can be used to override the default behavior.
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to_unless_current
<%=
link_to_unless_current("Comment", { :controller => "comments", :action => "new" }) do
link_to("Go back", { :controller => "posts", :action => "index" })
end
%>
In the example above it would yield the 'Go back' link if the current page was the 'new comment' page.
#James gave proper answer its just you are too young to take it right :)
<% #id_cards.each do |id| %>
<%=
link_to_unless_current(id.design_type, id_card_design_path(id.id), :class => 'btn') do
content_tag(:p, id.design_type, :class => :some_class
end
%>
<% end %>
I would like to combine 2 commands into 1, if its possible.
<%= render :partial => 'shared/logo' %>
<%= link_to 'Dashboard', root_url %>
I would like to call the logo in the shared directory and have it be a link at the same time.
How would I write this?
This should do it:
<%= link_to render(:partial => 'shared/logo'), root_url %>