Heroku rails app (text_area bug) - text

On the localhost all right...
But in heroku, i can not add more than 255 characters in the "about".
heroku error
We're sorry, but something went wrong.
_form.html.erb
<%= f.label :about %>
<%= f.text_area :about %>
show.html.erb
<p><%= #release.about %></p>
thanks!

Is about defined as a string in your database? To be longer than 255 characters it needs to be text. The reason why is because Heroku uses Postgres, who's strings can't be longer than 255 characters, while sqlite will allow it.

Related

Javascript Nesting Quotes not clear

What will be the Nesting Quotes for this
"javascript:window.open('http://localhost:9000/index.html#/mypage/detailspage\',
'details-page','width=300,height=250');"
I tried this not working
"javascript:window.open(\'http://localhost:9000/index.html#/mypage/detailspage\',
\'details-page\',\'width=300,height=250\');"
var y="javascript:window.open('http://localhost:9000/index.html#/mypage/detailspage\' ,\'details-page\',\'width=300,height=250\'')";
alert(y);
This works fine in browser i guess.
Thanks guys for the reply but it is now working for me. Actually my requirement is that from my app I am passing the value as a post request to another app in that app I am not able to see my code as I am sending it. Below is the example
<input type="hidden" name="value11" id="value11" ng-model="indexedArray[34]" value="javascript:window.open('http://localhost:9000/index.html#/abc/details-page\' ,\'details-page\',\'width=300,height=250\'');" autocomplete="off" class="ng-pristine ng-untouched ng-valid ng-empty">
In response I am getting this

pass an object inside ejs include statement

I need to pass an object inside an ejs include statement. I found a couple of questions on the same issue but I get a weird error when i do the following,
<div>
<%- include (folder/index , {"user": user}) %>
</div>
I get,
ENOENT: no such file or directory, open '/views/(folder/index.ejs'
Any idea why i get a enoent when i pass the object inline ?
if i simply do,
<%- include folder/index %>
this works
but i need to pass user object to index. is there a way to do this?
When you insert space after include, EJS will use include preprocessor directives (<% include folder/index %>); Although they are still supported, the new syntax is like the following:
<div>
<%- include('folder/index', {user: user}) %>
</div>
(See includes Documentation)
found a solution...
Yes. I missed the obvious.
var json_tmp = JSON.parse('<%- JSON.stringify(pass_object) %>');

How to fix the error of Maximum call stack size exceeded when using pattern lab?

In pattern lab Maximum call stack size exceeded error and I don't know why. I'm not doing anything that I haven't done before.
In 01-molecules/02-cart/cart.mustache I have this code
{{#miniCart}}
<div class="mini_cart_item">
<img class="mini_cart_image" src={{img}} alt="">
<div class="mini_cart_info">
<span>£{{price}}</span>
<h4 class="mini_cart_title">{{title}}</h4>
</div>
</div>
{{/miniCart}}
That data comes from 01-molecules/02-cart/cart.json. It works fine.
Then I have 02-organisms/mini-cart.mustache and the code is
<div class="mini_cart">
{{#miniCart}}
{{> cart}}
{{/miniCart}}
</div>
The cart comes from the molecule above, the data comes from 02-organisms/mini-cart.json. Is is the some json code just with more objects.
That {{> cart}} throws the Maximum call stack size exceeded error. If I remove that line of code and replace it with anything, like {{title}} the code just works.
What might be the problem?
To run pattern lab I am running this
/MyMAMP/www/2016/edition-node-gulp/node_modules/gulp/bin/gulp.js patternlab:serve
From google search I tried this
/MyMAMP/www/2016/edition-node-gulp/node_modules/gulp/bin/gulp.js patternlab:serve --stack_size=2048
but the result is the same thing.
Maintainer of Pattern Lab Node here.
{{> cart}} should be {{> molecules-cart}}
Give that a shot.
remove reference to 'miniCart' template inside the 'cart' template
this causes an infinite recursion in template engine

Call javascript functions on another file from an EJS templates in Harp.js

Trying to make a website with Harp.js here. I use ejs templates, and want to store some useful javascript functions in a central file. How do I do that? I tried to use
<% include _render_util.js %>
But it does not work (seems like js file is not parsed).
Any ideas?
Thanks!
Although there are ways of making this work (sometimes), it's not something that was deliveratly built into Harp.js. Forcing this behaviour often takes time to debug and causes unexpected issues.
Here is a quick experiment I made that works (I didn't throughly test it):
helpers.ejs
I created a say_hello function that takes a name and outputs the string Hello, {name}.
<%
say_hello = function (name) {
return 'Hello, ' + name;
}
%>
index.ejs
I include helpers.ejs (the file mentioned above) in the first line and then use the function in the second line. That outputs <h1>Hello, beautiful</h1>.
<% include helpers.ejs %>
<h1><%= say_hello("beautiful") %></h1>
Example gist: https://gist.github.com/jorgepedret/816c2b3985ad12cef022
There's an open issue on GitHub discussing this issue https://github.com/sintaxi/harp/issues/272
This example is more of a hack than a recommended solution. I've seen cases where it breaks in unexpected ways.

Cannot display variable from controller in erb file

I begin learning ruby and rails this week. So I follow some tutorial in the book I found in my school library.
I get to the point where I have main_controller.rb:
class MainController < ApplicationController
def welcome
#my_var = 5
end
end
and for my welcome.html.erb:
<h1>Welcome to the My Application</h1>
We currently have <%= #my_var %> visitors.
but when i run my server, all i got from localhost:3000/main/welcome is:
Welcome to the My Application We
currently have visitors.
as if the everything in <%= %> was not executed.
and I also try to insert puts 'welcome method is executed' to the main_controller.rb
and it does print the line.
So any help? I thank you in advance,
Fajarmf
Try <%=h #my_var %>
maybe you are rendering the page before you set the instance variables
There has no problem on your code, but when you change the code you need to refresh you browsers.

Resources