I am trying to add i18n to Refinery CMS with added Inquiries gem. Everything is fine until I add links for switching locales , like this :
= link_to_unless_current image_tag('flag_bulgaria.png'), locale: "bg"
Then routing error appears :
No route matches {:locale=>"bg", :controller=>"refinery/inquiries/inquiries", :action=>"new"}
I have added the refinery-I18n gem ,also have added locales in the initializer file . I have tried to add before filter for setting the locale in the application_controller , but no results .
I have read all the discussions about refinery i18n and found nothing about the problem .
I'm using rails 3.2.6 , refinery cms 2.0.4 , refinerycms-inquiries 2.0.3 .
Thank you for helping me .
Remember to use refinery.url_for in your link. Here is my language selector.
<ul id="menu1" class="dropdown-menu" role="menu" aria-labelledby="drop4">
<% Refinery::I18n.frontend_locales.each do |frontend_locale| %>
<li>
<%= link_to Refinery::I18n.locales[frontend_locale], refinery.url_for(:locale => frontend_locale) %>
</li>
<% end %>
</ul>
Related
I have created a Rails 3 app with devise and i also have a controller called 'account' . When an user signs in with devise's sign in view , he's redirected to a view of account controller. So the notifications od devise "sign in successful" etc are not displayed. When i tried adding
<%= devise_error_messages! %>
to this view It gave an error
NameError in Account#welcome
undefined local variable or method `resource' for #<#:0x4e9fe70>
Can anyone pls tell me how to make this account controller display devise's notifications??
I tried reading the docs in github but didnt help..
I guess we have do modify routes file as its showing error in resources..
Update1:
Layout file:
<div id="maincontent">
<div class="entry">
<% flash.each do |name, msg| %>
<%= content_tag :section, msg, :id => "flash_#{name}", :class => "flash" %>
<% end %>
<!--<p class="commentbar"> Signup</p>-->
<%= yield %>
</div>
</div>
Once you installed Devise, there will be a block of guide. One paragraph is about the messages:
Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
So, to display success messages/notice, use
<%= notice %>
<%= alert %>
These two are also Rails default helper to show flash messages. So you are fine with both Devise and other normal flash messages with this setting.
I'm using Angularjs in parts of my Rails app, which works great. But I'm wondering how to use an Angular value inside a link_to.
Here is my pseudo code:
%table
%tr{"ng-repeat" => "book in books"}
%td
{{book.title}}
%td= link_to "Show", book_url({{book.id}})
This gives me an error:
syntax error, unexpected '}', expecting tASSOC
This could also have to do with HAML causing the error, but how can I send the ID in the link_to?
This worked for me:
<li ng-repeat="deal in deals">
<%= link_to 'show,'#','ng-href' => "#{deals_path()}/{{deal.id}}" %>
</li>
Instead of a "link_to", I can of course use a normal link:
%a{href: 'books/{{book.id}}'} 'Show'
It work fine:
= link_to 'Show', URI::unescape(books_path('{{book._id}}'))
So I followed the refinery guide to create a custom layout template. I switched my about page to use my new template in the advanced options and it worked like a charm.
Then I created a new engine called clients and selected the new template in the advanced options of the clients page, which as you know defaults to clients - index.html.erb.
But the engine ignores my template. Why? I know I set it up correctly because it works in about page. The difference is that the about page is not part of a refinery engine and the clients page is. I found this SO question and have tried setting my engine's index.html.erb like so
<% content_for :body %>
<ul id="clients">
<% #things.each do |t| %>
<li>
<%= link_to t.name, refinery.ts_t_path(t) %>
</li>
<% end %>
</ul>
<%= render :layout => 'layouts/client' %>
to no avail. Any help would be much appreciated. Thanks!
I'm having an issue with Rails, I get the following error:
No route matches {:action=>"publish", :controller=>"businesses"}
The offending code:
<div id="searchDatesDiv" style="margin: 0 auto;">
<%= form_tag(publish_business_path, :method => :post) do %>
<%= submit_tag("Publish") %>
<% end %>
</div>
routes.rb:
resources :businesses do
member do
post 'publish'
end
end
rake routes:
registration GET /registrations/:id(.:format) registrations#show
publish_business POST /businesses/:id/publish(.:format) businesses#publish
businesses GET /businesses(.:format) businesses#index
POST /businesses(.:format) businesses#create
I can see the path defined in rake routes. Why am I getting this error? The form is also a POST method. Any help would be great! I've tried looking at similar questions on SO but haven't found one that works in my case :(.
Your business publish path requires an id parameter that you are not giving it. Pass the business object to the path helper thusly:
<%= form_tag(publish_business_path(#business), :method => :post) do %>
-Newbie to Ruby on Rails and integrating a few aspects of Twitter Bootstrap in (or at least trying :))-
I have a link in regular HTML with Twitter Bootstrap icons in it:
<li class="sidebar"><i class="icon-user"></i> Home</li>
(The i tag is for twitter's image icons)
If I were writing that same HTML in embedded Ruby, how could I still get the icon in there?
Right now I have:
<%= link_to content_tag(:li, "Home"), root_path %>
Is it possible to specify Twitter's tag in embedded ruby?
Also, should I specify the sidebar class in regular html or with :class => "sidebar"
Thanks!
Sure, just try something like:
<%= content_tag(:li, :class => 'sidebar') do %>
<%= link_to '#' do %>
<%= content_tag :i, '', :class => 'icon-user' %> Home
<% end -%>
<% end -%>
The shorter alternative I use is
link_to " ".html_safe, '#'
It's 'dirtier' but somewhat easier to understand.