I am using zurb-foundation version 4.1.6 in my rails project.
I have created this page skeleton (excerpt in haml):
%body
.row-fluid
%nav.top-bar
%ul.title-area
%li.name
%h1= link_to t('app.name'), root_path
%li.toggle-topbar.menu-icon
%a{:href => "#"}
%span Menu
%section.top-bar-section
%ul.right
%li.divider.hide-for-small
%li.has-dropdown
= link_to 'Something', '#'
%ul.dropdown
%li.has-dropdown= link_to 'Hello', '#'
.row{:style => "background-color: white; min-height: 800px;margin-top:-30px; padding-top:30px;"}
.large-12.columns
.section-container.horizontal-nav{"data-section" => "horizontal-nav", "data-options" => "one_up: false;"}
%section
%p.title{"data-section-title" => ""}= link_to 'Section', '#'
.content{"data-section-content" => ""}
%ul.side-nav
%li= link_to 'Link', '#'
%li= link_to 'Link', '#'
%li= link_to 'Link', '#'
%li= link_to 'Link', '#'
%li.divider
%li= link_to 'Link', '#'
/ %div.panel
/ = yield
= javascript_include_tag "application"
Now, the problem is that, the section collapses as if it has no content:
The layout works fine with the static css version of zurb foundation, but has problem with the gem.
Any help is highly appreciated.
This issue is resolved in zurb-foundation 4.2.1. Update your gems using bundle update.
Related
I am trying to add tags to a model. I need it to function with the following features:
Rendered as tags in the view using select2
User can create their own tags (ie. enter new tag then 'space' or ',')
User is prompted with existing tags to keep input consistant
i.e. the same way the "tags" box works on this site when posting a question!
I am 99% of the way there but each approach I take it seems that one part does not work.
Here are my software versions:
select2-rails (3.5.7)
simple_form (3.0.1)
acts-as-taggable-on (4.0.0)
Rails 4.03
Following Code: rendered correctly, but not able to add new tags before saving, prompt for existing tags works
#tags = ActsAsTaggableOn::Tag.all
<%= f.input :tag_list, input_html: { class: 'tags', multiple: true}, collection: #tags, value_method: :name %>
$('.tags').select2({
tokenSeparators: [',', ' '],
placeholder: "Add your tag here"
});
Following Code: rendered as a multi line text box, not tags via select2
#tags = ActsAsTaggableOn::Tag.all
<%= f.input :tag_list, input_html: { class: 'tags', multiple: true}, collection: #tags, value_method: :name %>
$('.tags').select2({
tags: true,
tokenSeparators: [',', ' '],
placeholder: "Add your tag here"
});
Following Code: rendered correctly, and can add new tags, but not prompt to select existing tags
#tags = ActsAsTaggableOn::Tag.all
<%= f.input :tag_list, input_html: { class: 'tags', multiple: true } %>
$('.tags').select2({
tags: true,
tokenSeparators: [',', ' '],
placeholder: "Add your tag here"
});
for anyone who finds this I ended up doing this to get it to work.
#tags = ActsAsTaggableOn::Tag.all.pluck(:name)
<%= f.input :tag_list, input_html: { class: 'tags', multiple: true, data: {options: #tags} } %>
$('.tags').select2({
tags: $('.tags').data('options'),
tokenSeparators: [' ', ',']
});
Happy to hear if there is a cleaner method.
I am new to Spree. I want to deface link_to rails helper.
i have spree/checkout/_new_user file and it contain following:
<%= link_to Spree.t(:login_as_existing), spree.login_path %>
i want to add remote: true to above link_to using deface.
Please Help.
You can replace links
Deface::Override.new(virtual_path: 'checkout/_new_user',
name: 'add remote true to link",
replace: "erb[loud]:contains('link_to Spree.t(:login_as_existing), spree.login_path'),
text: "<%= link_to Spree.t(:login_as_existing), spree.login_path, remote: true %>")
I'm trying to customize my dialog confirm the link_to in rails 4. But I do not understand why he rides the html as "confirm", and should be "data-confirm"!
I've tried a number of ways, and it is always generated "confirm", like this:
<%= link_to 'Delete', user, :method => :delete, :confirm => 'Are you sure?' %>
<a confirm="Are you sure?" rel="nofollow" data-method="delete" href="/user/13">Delete</a>
I followed this tutorial:
http://thelazylog.com/custom-dialog-for-data-confirm-in-rails/
and i used the example in tutorial, but also doesn't work
Confirm has been deprecated in rails 4.
So use new syntax:
<%= link_to "title", "#", data: {confirm: "Are you sure!"} %>
To get the same behavior in rails 7 you should use turbo_confirm key instead:
<%= link_to 'Delete', user,
data: {turbo_method: :delete, turbo_confirm: 'Are you sure?'} %>
Ok, so my problem is Capybara cannot click the submit button of a form (generated with simple forms) that resides in a modal(Bootstrap v2.3). Please note that the following code is very messy learners code. I am attempting to get it tested up so that I can refactor the hell out of it.
Modal code:
<div class="modal hide" id="updateModal">
<button type="button" class="close" data-dismiss="modal">×</button>
<div class="modal-header"
<h3>Update your score</h3>
</div>
<div class="modal-body">
<%= simple_form_for #update do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.input :newread , :label => "Amount Read", :placeholder => 'pages/screens/minutes #' , :input_html => { :maxlength => 5 } %>
<%= f.input :medium, :label=> "Medium Read", :collection => ["book", "manga", "game", "fgame", "net", "lyric", "subs", "news", "sent", "nico" ], :prompt => "Select medium read" %>
<% lang_list = Update::user_langs(current_user,ApplicationHelper::curr_round) %>
<%= f.input :lang, :label => "Language", :collection => lang_list, :prompt => "Select your language" %>
<%= f.input :repeat, :label => "Repeat number", :collection =>0..50 , :priority => '0' %>
<%= f.input :dr, :inline_label => 'Double Rowed?', :hint => 'Only to be used with Japanese books', :label => false %>
</div>
<div class="modal-footer">
<%= submit_tag 'Cancel', :class => "btn btn-danger", 'data-dismiss' => "modal" %>
<%= f.button :submit, 'Submit Update' , :class => "btn btn-primary"%>
</div>
<% end %>
</div>
Round Controller index function:
def index
#entrants = Round.includes(:user).where(:round_id => "#{ApplicationHelper::curr_round}")
if #entrants == nil
redirect_to root_url, :flash => { :error => "There are currently no users registered for this round." }
end
list = Round.where(:round_id => ApplicationHelper::curr_round).select(:tier).uniq
lang_list = Update.where(:round_id => ApplicationHelper::curr_round).select(:lang).uniq
#tier = list.map(&:tier)
#tier = #tier.sort{ |a,b| Tier::TIER_VALUES[a.to_sym] <=> Tier::TIER_VALUES[b.to_sym]}
#lang = lang_list.map(&:lang)
if signed_in?
#update = current_user.updates.build
end
end
Update_page_spec:
describe "Update Pages" do
before do
sign_in #omniauth fake signin
end
subject { page }
describe "a registered user submitting an update", :js => true do
before do
user = User.find_by_uid(123545)
user_round = user.rounds.create!(round_id: ApplicationHelper::curr_round, lang1: 'jp',
lang2: 'en', lang3:'zh', tier: 'Bronze', book: 10, manga: 10,
fgame: 10, game: 10, net: 10, news: 10, lyric: 10,
subs: 10, nico: 10, sent:10, pcount: 1010)
visit round_path(ApplicationHelper.curr_round)
end
it "should update successfully" do
click_link("Update")
fill_in('update[newread]', :with => '10')
select "book", :from => "Medium Read"
select "Japanese", :from => "Language"
click_button "Submit Update"
save_and_open_page
page.should have_selector('alert-success', :text => "Update successfully submitted")
end
end
end
So I do this and when I check what save_and_open_page sees and its the page with no changes at all. No evidence of the button having been pressed what so ever. So I figure that the modal being js generated might be a problem so I add , :js => true to the describe line, install the webkit driver and add Capybara.javascript_driver = :webkit to my spec_helper.rb file and run it again.
This time I am greeted to the "Signed in" flash from the top before block on the home page instead of being on the ranking page.
So I figure maybe this might turn out better with the selenium driver so I install that and try it again but this time my app complains about there being no one registered for that round. The only way for this to happen is if #entrants is nil and I have checked with pry that this is definitely not the case at least as far as the database is concerned.
Any help you guys can give will be GREATLY appreciated. I have no idea how to get this thing to press my button.
My recommendation:
Clean up the code as much as you can. That will help clarify what is happening, and what may be responsible for the unexpected behavior.
Don't rely on save_and_open_page to accurately show you what the driver is seeing exactly
You definitely need js for the Bootstrap modal
Get selenium working with Firefox so you can see on your screen if the modal is opening properly or not.
You may need the database_cleaner gem to properly access your db with the users you are creating.
you can also try the poltergeist/phantom gems for a js compatible driver. That has screenshot capabilities
Those pieces should show you what's happening with the modal.
So I loaded a Badge with an image just fine on rails 3.2
badges = [ {id: 1, name: 'Democratic-Society', description: "Voted for two bands", image: "demo_society2.gif"}
]
badges.each do |badge|
Merit::Badge.create!(badge)
end
But I just updated my code server to Rails 4.1... and now it gives the following error:
undefined method `image' for #<Merit::Badge:0x007f57949ba8f0>
I didn't change the code AT ALL. Didn't touch the merit initializer... or the application.rb... nothing. Can't quite figure out why it's not working. Here's the code from application.rb:
<% current_user.badges.each do |badge| %>
<%= image_tag (badge.image), :alt => badge.description, :float => "left" %>
<% end %>
Any help would be appreciated.
Alright the solution (in case anyone else runs into this) has to do with "custom_fields". Any custom fields have to be referenced as such (for some reason you didn't really need to do this in Rails 3.2 but you do in Rails 4.1)
So all I did was change the code to this:
badges = [ {id: 1, name: 'Democratic-Society', description: "Voted for two bands", custom_fields: {image: "demo_society2.gif"} }]
And then in my view:
<%= image_tag (badge.custom_fields[:image]), :alt => badge.description, :float => "left" %>
And VOILA!
Credit to marcosgugs over at github for the solution.