In want to create a table with Image and Headline in a Row.
The Frontent should show me for every Image I uploaded in the Backend an new Row.
I was trying to do that with
<f:for each={CONTENT#COLPOS} ...>
...
</f:for>
But unfortnatly there is no Array Output.
Can you fix this for me?
Thanks a Lot!
Related
I'm trying to import just the text from a div on a client's site into a Google sheets using the =IMPORTXML function so they can see everything on one sheet. The problem is that some pages have href tags wrapped around text, which if using =IMPORTXML(website, "[xpath]/text") gives me an error about the array overwriting the next cell. So I tried some of the tricks around the web (wrapping in =REGEXREPLACE, =JOIN, etc) and those got me the text of the div minus the text of the children.
For example, if I have this HTML
<div class="text">
I want to get this text and
this text, too
so what do I do?
</div>
In my sheet I get "I want to get this text and so what do I do?"
I found the solution for anyone else trying to do this:
=JOIN(CHAR(10),IMPORTXML("site","//div[#class='divclass']//text()"))
My mistake was using /text() instead of //text() The extra / was missing.
I'm quite new to rails and making an app that lists albums.
Each album should be loaded with two or three preview tracks from that album.
All I want to do is get the preview_url from the previews table where the album_id is the same as the current album.
In mysql, I would use a left join:
SELECT preview_id FROM previews WHERE album_id = '{$sanitized_album_id}'...
I'm just not sure how to achieve this in ruby.
I can't find a single example that isn't obsessed with posts and comments, and it just isn't clear enough to click yet.
My album controller method looks like this:
def show
#previews = Preview.where(album_id: #album.id).order(track_number: :asc)
end
And my show.html.erb file should loop the results with this (simplified) code:
<% #previews.each do |preview| %>
<iframe src="<%= preview %>"></iframe>
<% end %>
Although I see no errors and the right number of previews are loading for each album, the resulting code is nonsense to me.
I expect the preview variable inside the do loop to be something like
https://website.com/previews/1984628754234
Instead, it looks more like this:
#<Preview:0x00007fcc08572c38>
I guess this is the database resource or something, but not the actual data I [think I] requested.
All the youtubes and whatnot didn't help me and I've only got a few hairs left...
Any one of you fantastic coders able to spare a moment to show me my stupid mistakes?
Thank you!
This will load all the attributes of Preview, it internally is performing a SELECT *.
#previews = Preview.where(album_id: #album.id)
if looping through #previews you would need to call preview.preview_id on each entry to get the value for that column.
In order to get a query like you showed - SELECT preview_id - you could use Preview.where(album_id: #album.id).select(:preview_id). You would still need to call .preview_id on each entry in the list, but it wouldn't load additional data.
If you want to make a query but you just want the plain array of preview_id values, you can use Preview.where(album_id: #album.id).pluck(:preview_id).
See:
select
pluck
That's a Preview instance. You probably want a field on Preview like:
<iframe src="<%= preview.preview_url %>"></iframe>
You can't just load in the model.
Does anyone know how can I achieve following:
I need select2 dropdown which would appear 50 records. On reaching bottom scroll it would load another 50 etc...
On their site i found http://ivaynberg.github.io/select2/#infinite but this involve "search", so I have to type at least 3 chars to search db using ajax... I dont need that, I need 50 records loaded immediatelly on load and visible inside select2 and rest per scrolling...
Does anyone know if this can be achieved with select2 and how (to post me example)... If not is there any another plugin which could allow me this?
Thanks!
Set property minimumInputLength:0 so it fetches the first records immediately, not after 3 characters.
I've been attempting to find a solution to this problem for about the last 12 hours and simply have to admit defeat and ask the question...
I am currently working on a project which involves added a start rating feature to a product.
the_number = number_with_precision(product.no_of_stars, :precision => 0) gives me the average star rating for the product. I can display the number (eg 4) on the index.html.erb page but cannot for the life of me get it to render a star jpg for for each number (instead of the number).
I am aware of the difference between <%= and <% etc however because this is my first post, I'm unable to copy and past the code I've used :-(
SO... the_number (for example) would give me 4, however the following loop construct within my index.html.erb file keeps throwing an error reading
undefined methodtimes for "4":ActiveSupport::SafeBuffer`
the_number.times do
img src="my-image.jpg" alt=""
end
I understand the snippet above is not wrapped in the correct tags, but as explained before, it will not allow me too. Please assume that the 1st and 3rd line are wrapped in ruby tags without the '=' and the image is wrapped in the relevant html img tag. You can also assume that the rating 'system' works correctly.
Any help would be greatly appreciated :-)
Thanks
the_number.to_i.times do
img src="my-image.jpg" alt=""
end
would <%= ... Integer(expression resulting in 4) %> work for you?
to this you can append times and continue with the loop
such as
Integer(the_number).times do
img src="my-image.jpg" alt=""
end
Try casting the_number to an integer:
the_number.to_i
Then you should be able to call times on it.
thanks in advance for any input. I am using struts2 and jquery in this app.
I tried to use displaytag for pagination but my tables have images and there wasn't a way I could make displaytag work with images.
So now I have custom coded pagination which uses <s:subset> which works great so far except that I don't know how to make it go to another page.
Basically in <s:subset> I just want to change the start attribute and then refresh my JSP. My code evaluates the start attribute correctly with a given page number.
My s:subset tag is like below,
<s:subset source="pageableList.pagedList" count="pageableList.pageSize" start="pageableList.start" >
<s:iterator>
I think I want to use <s:url> to display my clickable page numbers but I'm having trouble there.
I have my page numbers in a list (which I evaluate in my action class right after my search completes), then in my JSP where I need to display the clickable page numbers, I iterate through the list, displaying the page numbers like below -
<s:iterator value="pageNumList" > | <a href='#'> <s:property/> </a> </s:iterator>
I guess I need to pass the clicked value of page number to the action class, then since the search results are in a list in the action class, without hitting the database again just display the results page with the new value of start attribute.
Any ideas how I might do that? I have been considering using a Decider attribute with <s:subset> but maybe there is a simpler way?
Thanks again for any input.
Regards,
veeCan
If you do not want to hit your DB again, cache the results of the initial query in RAM in your Action class (reference a static cache somewhere). Also, you don't have to go with a cache-all-or-nothing approach -- you can cache the first N pages and then when you near the end of the cache, fetch the rest. If you do it right, you can maintain minimum RAM footprint but preserve a snappy user experience that leverages user think time (depends on your app).