Comments (3)
Hi Brett,
only including a module doesn't make it available in the view. I hate
helpers and I'm gonna vent my anger in a blog post soon ;-)
Try that:
Class MenuCell < Cell::Rails
...
helper UrlHelper
and lemme know if that helps.
Nick
On Mon, Apr 11, 2011 at 4:32 PM, brett-richardson <
[email protected]>wrote:
Hey, I've been trying to get Cells to render a menu that links to a list of
sub-domains.I have gone through @wingrunr21's recent pull request for adding the UrlFor
module, but I'm unsure how one should go about getting this working.My cell looks like this:
class MenuCell < Cell::Rails include ActionController::UrlFor include UrlHelper def primary render end end
But I have also tried this method too:
module UrlHelper def with_subdomain( subdomain ) subdomain = ( subdomain || '' ) subdomain += '.' unless subdomain.empty? [subdomain, request.domain,
request.port_string].join
enddef url_for( options = nil ) if options.kind_of?( Hash ) && options.has_key?(
:subdomain )
options[:host] = with_subdomain(
options.delete( :subdomain ) )
endsuper end end module Cell class Rails < AbstractController::Base include ActionController::UrlFor include UrlHelper end end
Ideally I think Cells should be able to handle a link_to call like this:
%li= link_to mod.name, root_url { :subdomain => mod.subdomain }
Do you know what needs to be done here?
Reply to this email directly or view it on GitHub:
#48
from cells.
brett, including the ApplicationController::UrlFor module in your Cell should be all that is necessary for those types of links to work. I'm using them right now in my site.
root_url(:subdomain => :foobar)
Cell:
class NavigationCell < Cell::Rails
include ActionController::UrlFor
def nav_links
...
end
end
View:
%li
= link_to(root_url(:subdomain => :courses)) do
%span.pictos W
Courses
%li
= link_to(root_url(:subdomain => :resources)) do
%span.pictos p
Resources
%li
= link_to(root_url(:subdomain => :projects)) do
%span.pictos e
Projects
%li
= link_to(root_url(:subdomain => :alumni)) do
%span.pictos g
Alumni
from cells.
Ah, that's great! Thanks. :)
from cells.
Related Issues (20)
- Cells + Airbrake issue - double exceptions raised HOT 2
- Using Cells with Rails engine that has html.erb partials not being picked up HOT 5
- Confusing file structure - views or view? HOT 7
- Template Missing ... again! HOT 21
- how to render erb templates when haml/hamlit and erb extensions installed HOT 3
- Render an array inside view cell HOT 1
- Escaping implementation seems to be a glaring LAYER VIOLATION, methinks.
- Is there some way to do html escaping default with options?
- Publish latest version on Rubygems HOT 10
- should default to file_name.html.erb or .haml HOT 1
- Can't get form_with to work from a cell in Rails 6 HOT 3
- License HOT 1
- Form Input renders as raw text in cell HOT 1
- Feature Request: Support Recyclable Cache Key
- Still maintained? Documentation URLs broken. HOT 9
- Default cache key produces clashes HOT 4
- Options hash is same instance passed to each cell when using collections HOT 1
- Slim v5 breaks cells HOT 9
- Ruby 3.0 ArgumentError: wrong number of arguments error with keyword args for Cell::Testing
- Ruby 3.0 ArgumentError: wrong number of arguments error with Caching
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cells.