in discussion Help / Support » Inserting code into .liquid
Hey,
I am not able to use rails helpers in liquid code (like form_for, check_box_tag)..
It gives an error saying Unknown tag 'form_for'
Has anybody used it before?
Hey,
I am not able to use rails helpers in liquid code (like form_for, check_box_tag)..
It gives an error saying Unknown tag 'form_for'
Has anybody used it before?
Manuel,
As you may have already seen on the homepage, Chameleon is not under active development anymore. I stopped working on it more than a year ago. Meanwhile, I forgot a lot about how it works, so I might not be able to help you completely.
As for your problem, in the .liquid templates you're not using the User model (which is in app/models/user.rb), but the UserDrop (which is in lib/chameleon/liquid/user_drop.rb). So, you need to add you 'get_current_user' method to the UserDrop.
(If that doesn't work, you might need to add the 'get_current_user' method to the User model, and afterwards add a new 'get_current_user' to UserDrop which simply calls the other one.)
I hope this helps,
JW
sorry, i say image_tag tag, but i returns the url with the image_path tag
i have a similar problem,
i have many users in a website and i need restrict my image_tag tag to only find the asset for the present user.
i have this code:
module TextFilters
include ActionView::Helpers::TagHelper
def image_path(name, size = 'original')
@user.assets.find_by_name(name).asset.url(size)
end
end
logically this returns an error, since to @user it does not exist, i need to execute a method in the User model, for example: User.get_current_user
class User < ActiveRecord::Base
def get_current_user
User.find_by_subdomain(current_subdomain)
end
end
Liquid error: undefined method ‘get_current_user’ for #
<class:0x2f8c648/>
they have an idea?
i try with session[:user] but don't works too
Hi Eugenio,
rcov isn't really required, the only thing it's used for is to check the test coverage, but since that's only of interest to someone actually writing tests, you won't need it.
Oh, and, I'd also like to warn you, Chameleon is not being very actively maintained anymore. As you may have seen, the latest release is already quite old, Chameleon still uses an old Ruby on Rails version, not all desired features have been implemented… I personally would be glad to help you with any problems you would encounter while trying to set up a blog using Chameleon, but I most likely won't be making any changes to the Chameleon code anymore. Of course, you can still make changes yourself, and I'd be glad to include them in the code.
Greetings,
JW
Hello, I'd like to implement this rather easily escalable blog as a multimedia one for musicians. The first issues I encountered was the old dependencies it has.
Why does it need rcov, which needs actionwebservice, which asks for specific old versions of actionpack and activerecord? How could I avoid it?
Thank you;
Eugenio.
Hi,
First of all, did you create a database (an empty one), and add its settings to the file config/database.yml? You can create an empty database using a program such as phpMyAdmin.
Afterwards, run the command "rake db:schema:load" to load the database schema (this will set up the tables). When that's done, run "rake db:fixtures:load" to load some of the content for the database.
Greetings,
JW
i've just download the latest chameleon-0.6.2 and i can't start it…
i guess it was because it can't find its database… but then i tried "rake db:create:all", but it give me error message
(in D:/Aptana Studio/chameleon-0.6.2)
rake aborted!
no such file to load — rcov/rcovtask
D:/Aptana Studio/chameleon-0.6.2/rakefile:10
(See full trace by running task with —trace)
what's happening here… i've follow the readme file and i'm still stucked….
Just now, version 0.6.2 of Chameleon was released. Version 0.6.2 is a quite large release, that adds some new features and fixes some bugs.
In this release many bugs were fixed, some severe ones that would prevent you from creating new posts, and some less important ones. In general, these bug fixes will make Chameleon more stable, so it's recommended you upgrade to this version. I'd also like to thank everyone who reported bugs.
Additionally, this release also ships with a few new features. Along the same line, this release adds unit tests for most of the Chameleon code, which made it possible to find a few bugs, and will make it easier to solve issues in the future. We upgraded to Rails 1.2, which is more stable than Rails 1.1, and includes some new features that should also ease development in the future. Finally, James also added a live preview and an auto-save function to the write page, which should make working with Chameleon easier.
You can download Chameleon 0.6.2 (Beta) at http://chameleon.wikidot.com/download, and follow the instructions in the README included in the package to install it. These instructions and a lot more information are also available on the website.
Because Chameleon is still in beta, some problems might occur. Report any issues in the bug tracker.
James,
Could you add the following Liquid code to your template, and then copy what it returns from the HTML source code?
{{ 'br' | tag }}
{{ 'test.png' | image_tag }}
{{ 'test.png' | imagemagick_tag }}
Normally, it should return something like this:
<br />
<img alt="Test" src="/images/test.png?" />
<img alt="Imagemagick?id=test" src="http://0.0.0.0:3000/blog/imagemagick?id=test.png" />
JW
Hi JW,
In the source is says:
Liquid error: undefined method ‘tag’ for #<Liquid::Strainer:0x2fecf20>
Any idea about what this means?
James
Hi James,
Could you use the "View Source" option in your browser, to find what's behind the #. Normally there should be something between a < and a > there. Maybe that could help us get a clue.
JW
Hi JW,
Still getting the same old 'Liquid error: undefined method ‘tag’ for #'… i inserted the above and reset the server and nothing…
Any other ideas?
James
Where did you get the FlickrController? Can I see its source code? The code for @photos is probably in there somewhere.
JW
I dont know what to set in the [something]. I have a flickr controller where the @photos is loaded with flickr pics. how to put the same photos variable in blog controller with flickr pics loaded.
Hi,
You are right, if the include works outside the 'for' loop but not inside it, it means there's nothing in the 'photos' variable. If you want that variable to be in blog.liquid, you need to create it in app/controllers/blog_controller.rb, in the "load_liquid_variables" function. So, at the end of file, you need to change the code to something like:
def load_liquid_variables
@site = Liquid::SiteDrop.new(self)
@option = Liquid::OptionDrop.new
@user = @session["user"]
@photos = [something]
end
You need to replace the "[something]" with the code to load the photos, but I don't know what that code is (I don't know exactly how the rflickr gem works). Could you try this?
JW
sorry typo the photos variable in flickr controller is not passed into the blog.liquid
Hey JW,
{% for photo in photos %}
{% include 'flickr/flickr' with photo: photo %}
{% endfor %}
This code of flickr is not working in blog.liquid When I remove the for loop and call the 'flickr' partial it is going into the flickr partial and printing the text I kept in partial…. i think the 'photos' variable in flickr controller is being passed into the blog.liquid Any help….
Hi James,
It seems you have to add another line to app/helpers/blog_helper.rb, it becomes:
module BlogHelper
include ActionView::Helpers::TagHelper
include ActionView::Helpers::AssetTagHelper
end
I hope this works.
JW
Hi JW,
I placed the code into the clog controller and got the following error:
Liquid error: undefined method ‘tag’ for #
Thanks for the help so far,
James