MissingTemplate : Render partial in Rails 3.2.3 [closed] - render

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Hi I am new to Ruby on Rails and I am following Michael Hartl's book online.
In Partials section of his book. The code he used to render partial was <%= render 'layouts/stylesheets' %>
but I get this error.
I read the API and tried this <%=render :partial => "/layouts/stylesheets" %> but still can't figure this one out.
Thanks for all the help!

In your view, make sure you have the following structure:
- views
- layouts
- application.html.erb
- _stylesheets.html.erb
Your code should be:
<%= render 'layouts/stylesheets' %>
If your main template is inside the layouts folder:
<%= render 'stylesheets' %>

I overlooked the filename. When I initially created the file, after the .erb extension, I accidentally put a space after.

Related

Middleman not rendering markdown and erb

I'm working on a project using Middleman. In one of the pages (videos.html.markdown.erb), I'd like to add partials working with both markdown and Middleman helpers.
<h3><%= video.title %> : RĂ©cit de tournage</h3>
<%= partial "partials/shootandlook1" %>
</div>
It works fine except that Markdown is not converting into HTML... :-(
I named my partial _shootandlook1.html.markdown.erb and my page videos.html.markdown.erb.
I really don't understand what I did wrong... Could someone please help me?
The whole source code is here.
Many, many thanks in advance!
This should work fine if you name your page template file videos.html.erb, and name your content partial _shootandlook1.md.
The Markdown file will be processed first, then inserted into the ERB template appropriately.
I usually find that it's best to avoid having multiple template formats in one file, unless the format explicitly supports blocks (like Haml)

How to get the the chosen image and show it on the same page using jquery ajax [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I want to show the uploaded image on the same page without refreshing the page .
<form action='xyz.php' method='post' enctype='multipart/form-data'>
<input type='file' name='image' id='image'>
<input type='submit' name='ok' id='ok' value='upload'>
</form>
<div id='uploadedImage'></div>
<script>
$(document).ready(function(){
$('#ok').click(function (e) {
e.preventDefault();
// then should be the jquery ajax call and response ?
// help with this code .
});
});
</script>
Check out this jQuery File Upload plugin.
By standart means you can't (you can, but in two words you have to write many code with hiding inputs and showing buttons). But there are several good plugins you can use. You can check https://github.com/valums/file-uploader. It is open-code, so you can either use it or you can see how ajax upload is implemented

Rails HAML how to do a simple loop? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
How to do a simple HAML loop. That would be like this in ERB view:
<table>
<tr>
<th></th>
<th></th>
</tr>
<%= #price. each do |row| %>
<tr>
<td><%= row.year %></td>
</tr>
<% end %>
</table>
Example just tried this:
%table
%tbody
%tr
%th year
%th price
Error:
Inconsistent indentation: 3 spaces were used for indentation
In HAML the indentation matters, and it means the code nesting, which allows you not to use closing tags and end statements in Ruby code. To make HAML understand your nesting properly, all the indents need to be the same size, 2 spaces for example.
So, your ERB code will look the following:
%table
%tr
%th
%th
- #price. each do |row|
%tr
%td= row.year

rendering Ruby statements inside of rails views?

So in my DB I want stored a ruby/HTML statement in the Database Table such as -
p This site is owned from 2000 - #{Time.now.year} by Acme Widget Co. /p
Or let's say that I want people to be able to include in other code snippits - e.g.
A client wants to run in a show view in the middle of a paragraph some magical partial such as #{render 'my_magical_code'}
On the view I have this being rendered as <%= raw(#page.content) %>
But its like a double rendering and rails will just put on the page #{render 'my_magical_code'} or #{Time.now.year}
So can / how do I solve this?
Thanks!
There are work arounds but I think the most proper way to solve your problem is to store your information in a better way. Add a migration to your model with a year_founded and company rows. You can then call these in your views rather than storing the HTML. Eg. This site is owned from <%= #object.year_founded %> to <%= Time.now.year %> by <%= #object.company %>

XUL Toolbar is not in FF toolbar list [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
Ive got a following problem.
I made a XUL toolbar. Toolbar works correctly, it is displayed correctly and works fine. The only problem is that it is not displayed in the list of toolbars in Firefox. I want it to be in this list - i want to be able to hide/show it from context menu.
What my problem could be in? XUL is organized in following way:
<?xml version="1.0" encoding="windows-1251"?>
<overlay id="myOverlayName"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="json.js"></script>
<script type="application/x-javascript" src="md5.js"></script>
<script type="application/x-javascript" src="sd.js"></script>
<toolbox id="navigator-toolbox">
<toolbar id="somebarid" mode="full"
customizable="false"
toolbarName="toolbarname"
accessibleType="1020"
context="toolbar-context-menu" >
...
...
</toolbar>
</toolbox>
</overlay>
toolbarName="toolbarname" should :
1) be spelled toolbarname
and
2) exactly match <em:name>toolbarname</em:name> string in RDF.
After that it works well.

Resources