Search Results

Search found 1976 results on 80 pages for 'helper'.

Page 5/80 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • A really smart rails helper needed

    - by Stefan Liebenberg
    In my rails application I have a helper function: def render_page( permalink ) page = Page.find_by_permalink( permalink ) content_tag( :h3, page.title ) + inline_render( page.body ) end If I called the page "home" with: <%= render_page :home %> and "home" page's body was: <h1>Home<h1/> bla bla <%= render_page :about %> <%= render_page :contact %> I would get "home" page, with "about" and "contact", it's nice and simple... right up to where someone goes and changes the "home" page's content to: <h1>Home<h1/> bla bla <%= render_page :home %> <%= render_page :about %> <%= render_page :contact %> which will result in a infinite loop ( a segment fault on webrick )... How would I change the helper function to something that won't fall into this trap? My first attempt was along the lines of: @@list = [] def render_page( permalink ) unless @@list.include?(permalink) @@list += [ permalink ] page = Page.find_by_permalink result = content_tag( :h3, page.title ) + inline_render( page.body ) @@list -= [ permalink ] return result else content_tag :b, "this page is already being rendered" end end which worked on my development environment, but bombed out in production... any suggestions? Thank You Stefan

    Read the article

  • Using Rails Helper Methods within ActionRecord Queries?

    - by Pygmalion
    I have a table of events (in a sqlite3 database for what it's worth) with a column called "when" that contains a timestamp detailing precisely when the event that particular row denotes is set to occur. Right now, I have @events = Event.find(:all) in my controller and I am using template helper methods to calculate where to place each event on my display page based on the day of the week it occurs on. For example: <% if(event.when.wday == 6) %> # DO SOMETHING <% end %> I want to abstract this logic to the controller however. My idea was to do the following: @thursday_events = Event.find(:all, :conditions => ["when.wday=4"]) Obviously (I guess?) this didn't work. Throwing the error "SQLite3::SQLException: near "when": syntax error: SELECT * FROM "events" WHERE (when.wday=4)". I'm assuming this is because I tried to use a helper method within a find condition but I don't know a better way to do this. Any advice? Thanks!

    Read the article

  • A really smart rails helper needed

    - by Stefan Liebenberg
    In my rails application I have a helper function: def render_page( permalink ) page = Page.find_by_permalink( permalink ) content_tag( :h3, page.title ) + inline_render( page.body ) end If I called the page "home" with: <%= render_page :home %> and "home" page's body was: <h1>Home<h1/> bla bla <%= render_page :about %> <%= render_page :contact %> I would get "home" page, with "about" and "contact", it's nice and simple... right up to where someone goes and changes the "home" page's content to: <h1>Home<h1/> bla bla <%= render_page :home %> <%= render_page :about %> <%= render_page :contact %> which will result in a infinite loop ( a segment fault on webrick )... How would I change the helper function to something that won't fall into this trap? My first attempt was along the lines of: @@list = [] def render_page( permalink ) unless list.include?(permalink) @@list += [ permalink ] page = Page.find_by_permalink content_tag( :h3, page.title ) + inline_render( page.body ) @@list -= [ permalink ] else content_tag :b, "this page is already being rendered" end end which worked on my development environment, but bombed out in production... any suggestions? Thank You Stefan

    Read the article

  • Add Form In Every Row with table helper Codeigniter

    - by wibi
    Hi i am creating table using table helper, but in every row i want to add form, in html like this : <table> <form action=""> <tr> <td><input type="text" name="name2"></td> </tr> </form> <form action=""> <tr> <td><input type="text" name="name2"></td> </tr> </form> </table> But i want in table helper: I have tried this one: $this->table->add_row( form_open('myAction'). form_input('name'.$i), form_submit('Submit') form_close() ); And I use firebugs to inspect element produces, like this: <table> <tr> <form action="myAction"> <td><input type="text" name="name1"></td> </form> <td><input type="submit"></td> </tr> </table> why tag doesn't show at the last tag , but show at the first tag . Thanks

    Read the article

  • using jquery draggable can you create a helper based on the dragged item?

    - by user169867
    I wish to create a custom helper based on the element being dragged. I'm dragging documents and I'd like the document's number to be part of the custom helper. I know how to create a helper during init like this: helper: function() { return $("<div class='fax16'></div>"); } But what I really want to do is maybe in response to the start event get access to the element being dragged and use some of its properties to set the helper. Something like: start: function(event, ui) { var docID = //somehow access the dragged element ui.helper = $("<div class='save16'>" + docID + "</div>"); //Set drag Helper } Can this be done?

    Read the article

  • how to add styles to actionview helper tags?

    - by ZX12R
    how do i add styles to actionviews helper tags. like the following <%= link_to "Home", :controller=> "home", :action=> "index", :style=>{:position=>"absolute", :top=>"0px"} %> is something like the above achievable. I dont want to add css classes. Thanks.

    Read the article

  • Getting field of type bytea in helper table when using GenerationType.IDENTITY

    - by dtrunk
    I'm creating my db scheme using Hibernate. There's a Table called "tbl_articles" and another one called "tbl_categories". To have a n-n relationship a helper table ("tbl_articles_categories") is needed. Here are all necessary Entities: @Entity @Table( name = "tbl_articles" ) public class Article implements Serializable { private static final long serialVersionUID = 1L; @Id @Column( nullable = false ) @GeneratedValue( strategy = GenerationType.IDENTITY ) private Integer id; // other fields... public Integer getId() { return id; } public void setId( Integer id ) { this.id = id; } // other fields... } @Entity @Table( name = "tbl_categories" ) public class Category implements Serializable { private static final long serialVersionUID = 1L; @Id @Column( nullable = false ) @GeneratedValue( strategy = GenerationType.IDENTITY ) private Integer id; // other fields public Integer getId() { return id; } public void setId( Integer id ) { this.id = id; } // other fields... } @Entity @Table( name = "tbl_articles_categories" ) @AssociationOverrides({ @AssociationOverride( name = "pk.article", joinColumns = @JoinColumn( name = "article_id" ) ), @AssociationOverride( name = "pk.category", joinColumns = @JoinColumn( name = "category_id" ) ) }) public class ArticleCategory { private ArticleCategoryPK pk = new ArticleCategoryPK(); public void setPk( ArticleCategoryPK pk ) { this.pk = pk; } @EmbeddedId public ArticleCategoryPK getPk() { return pk; } @Transient public Article getArticle() { return pk.getArticle(); } public void setArticle( Article article ) { pk.setArticle( article ); } @Transient public Category getCategory() { return pk.getCategory(); } public void setCategory( Category category ) { pk.setCategory( category ); } } @Embeddable public class ArticleCategoryPK implements Serializable { private static final long serialVersionUID = 1L; @ManyToOne @ForeignKey( name = "tbl_articles_categories_fkey_article_id" ) private Article article; @ManyToOne @ForeignKey( name = "tbl_articles_categories_fkey_category_id" ) private Category category; public ArticleCategoryPK( Article article, Category category ) { setArticle( article ); setCategory( category ); } public ArticleCategoryPK() { } public Article getArticle() { return article; } public void setArticle( Article article ) { this.article = article; } public Category getCategory() { return category; } public void setCategory( Category category ) { this.category = category; } } Now, I'm getting a serial type what I wanted in my articles table as well as in my categories table. But looking into my helper table, there aren't the expected fields article_id and category_id each of type integer - instead there are article and category of type bytea. What's wrong here? EDIT: Sorry, forgot to mention that I'm using PostgreSQL.

    Read the article

  • Problem using HTML Link Helper in Cakephp 1.3.1

    - by ShiVik
    Hello all I am having a problem using $html-link helper in my view. Consider this snippet... /views/nodes/packages.ctp <li><?php echo $html->link( "Package 1", array( "packages", "package1" ) )?></li> Now when I click on the link, the address in address bar appears like http://www.server.com/nodes/packages/packages/package1 Why is this happening? I haven't changed anything in my default routing configuration file. Regards Vikram

    Read the article

  • ASP.NET MVC Referencing Html Helper from a view

    - by Dan
    I've written an Html Helper called DetailsForm to reduce repetition when displaying fields in a view. Within a view - actually a partial view, ascx file - I can refer to it like this: Storyboard.Helpers.DetailsForm.LabelAndData(Html, m => m.id) But would like to refer to it like this: LabelAndData(Html, m => m.id) A 'using' directive doesn't seem to be allowed in the ascx file. Is there an equivalent?

    Read the article

  • How to create a subject helper method in Rspec2

    - by Hedgehog
    In rpsec 2.12 I expected this helper method definition to work: module X private def build_them(type) puts 'Catching the star' end end context 'public/private instance methods' do subject{ Class.new { extend(::X) } } def subject.build(type) puts "Throwing a star" build_them(type) end it{ should respond_to :build} end The actual result is a failed spec: expected #<Class:0x00000002ea5f90> to respond to :build I expected the example to pass Any suggestions on how to do this correctly?

    Read the article

  • Rails error_messages helper

    - by Bob
    This is a very common piece of code <% form_for :blah... do |f| %> <%= f.error_messages %> First name: <%= f.text_field :first_name %><br /> .... <% end %> error_messages is a helper method but I am having a hard time finding the documentation for it, why is that?

    Read the article

  • build-helper-maven-plugin add-source does not working when trying to add linked resources

    - by Julian
    I am new to maven and hit a problem that looks easy in the first place but I already kept me busy for a whole day about and no way to get it working. First as part of running eclipse:eclipse plugin I create a linked folder like below: <linkedResources> <linkedResource> <name>properties</name> <type>2</type> <location>${PARENT-2-PROJECT_LOC}/some_other_project/properties</location> </linkedResource> <linkedResource> <name>properties/messages.properties</name> <type>1</type> <location>${PARENT-2-PROJECT_LOC}/some_other_project/properties/messages.properties</location> </linkedResource> And then I am adding that folder as a source folder like below: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.7</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>properties</source> <source>some_real_folder</source> </sources> </configuration> </execution> </executions> </plugin> However when I am looking at the generated .classpath in eclipse the “some_real_folder” is there but the “properties” is not. It looks like by default the build-helper-maven-plugin will check if the folder is there and if it is not it won’t add it. I am using maven 3.0.4 outside eclipse to run the build and I can see in the maven logs something like this: [INFO] Source directory: <some path>\properties added. This is my project structure: project1 \-- properties (this is the real folder) project2 \-- some_real_folder \-- properties (this is the link resource pointing to the project1/properties folder) All I need is to have both "some_real_folder" and the linked resource "properties" added to the .classpath of the project2

    Read the article

  • image url helper for sinatra?

    - by yaya3
    I'm looking for an image url helper for sinatra that allows me to do something similar to staticmatic's, where I can shortcut to a relative path like so... =img "me.jpg" Can anybody point me in the direction to where this might be online, or where I could learn how to write one, or provide an example of one they have already written Many thanks

    Read the article

  • breaking datetime into constituent parts ASP.NET MVC form

    - by nick
    hi guys, i have searched the web relentlessly for this and have not found anything - which is surprising because i would think it is such a common scenario! Basically, on my model i have a DateTime field which i wish the user to populate through a form. I am using the Html helper to render all other parts of the form (along with validation) So this question is in two parts... Html Helper Firstly, is there any way to use the Html helper to split the DateTime field to be rendered as the three constituent parts of a date: day, month, year (since i do not care about the time part). This could be rendered as text boxes, drop down lists or a combination of both. Model Binding And then when the form is posted, what is the best approach for binding back up to the model? I have seen Scott Hanselmann's solution to this, but it seems a little bloated for what i need - i was hoping for a slightly more elegant solution. Is it recommended to extend DefaultModelBinder and set that as default binder (since all dates would be handled in this way) or write a class that implements IModelBionder and set it as the default binder for the DateTime type? Thanks for all the help in advance :-) i'm loving MVC but it's infuriating me that something so trivial is causing so much headaches!

    Read the article

  • Magento Onepage Success Conversion Tracking Design Pattern

    - by user1734954
    My intent is to track conversions through multiple channels by inserting third party javascript (for example google analytics, optimizely, pricegrabber etc.) into the footer of onepage success . I've accomplished this by adding a block to the footer reference inside of the checkout success node within local.xml and everything works appropriately. My questions are more about efficiency and extensibility. It occurred to me that it would be better to combine all of the blocks into a single block reference and then use a various methods acting on a single call to the various related models to provide the data needed for insertion into the javascript for each of the conversion tracking scripts. Some examples of the common data that conversion tracking may rely on(pseudo): Order ID , Order Total, Order.LineItem.Name(foreach) and so on Currently for each of the scripts I've made a call to the appropriate model passing the customers last order id as the load value and the calling a get() assigning the return value to a variable and then iterating through the data to match the values with the expectations of the given third party service. All of the data should be pulled once when checkout is complete each third party services may expect different data in different formats Here is an example of one of the conversion tracking template files which loads at the footer of checkout success. $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId()); $amount = number_format($order->getGrandTotal(),2); $customer = Mage::helper('customer')->getCustomer()->getData(); ?> <script type="text/javascript"> popup_email = '<?php echo($customer['email']);?>'; popup_order_number = '<?php echo $this->getOrderId() ?>'; </script> <!-- PriceGrabber Merchant Evaluation Code --> <script type="text/javascript" charset="UTF-8" src="https://www.pricegrabber.com/rating_merchrevpopjs.php?retid=<something>"></script> <noscript><a href="http://www.pricegrabber.com/rating_merchrev.php?retid=<something>" target=_blank> <img src="https://images.pricegrabber.com/images/mr_noprize.jpg" border="0" width="272" height="238" alt="Merchant Evaluation"></a></noscript> <!-- End PriceGrabber Code --> Having just a single piece of code like this is not that big of a deal, but we are doing similar things with a number of different third party services. Pricegrabber is one of the simpler examples. A more sophisticated tracking service expects a comma separated list of all of the product names, ids, prices, categories , order id etc. I would like to make it all more manageable so my idea to do the following: combine all of the template files into a single file Develop a helper class or library to deliver the data to the conversion template Goals Include Extensibility Minimal Model Calls Minimal Method Calls The Questions 1. Is a Mage helper the best route to take? 2. Is there any design pattern you may recommend for the "helper" class? 3. Why would this the design pattern you've chosen be best for this instance?

    Read the article

  • jQuery UI sortable scroll helper element offset Firefox issue

    - by James
    I have a problem with a jQuery UI 1.7.2 sortable list in Firefox 3.6, IE7-8 work fine. When I'm scrolled down a bit, the helper element seems to have an offset of the same height that I'm scrolled down from the mouse pointer which makes it impossible to see which item you originally started dragging. How do I fix this or work around the issue? If there is no fix what is a really good alternative drag-able plugin? Here are my initialization parameters for the sortable. $("#sortable").sortable( {placeholder: 'ui-state-highlight' } ); $("#sortable").disableSelection();

    Read the article

  • jQuery UI sortable('cancel') - this.helper is null

    - by Kerry
    I am trying to disable a sortable element from sorting when it has been double clicked. When I try to disable it, even without a condition, it gives me the error 'this.helper is null'. $('.roundedBox:first', division).sortable({ start: function( event, ui ) { if( true === true ) { $(this).sortable('cancel'); } $(this).parent().data( 'sorting', true ); }, stop: function() { $(this).parent().data( 'sorting', false ); }, items: '.department', update: function() {}, placeholder: 'department-placeholder' }) Any ideas on how I can do this? I don't need it to be this method. Literally anything thing that stops it will work. The problem is, sorting starts on a single click, but I have another action bound to double click. If it's double clicked, I don't want it to drag.

    Read the article

  • jQuery UI sortable issue with helper offset value being same as scroll offset on FireFox only

    - by James
    I have a problem with a jQuery UI 1.7.2 sortable list in Firefox, IE7-8 work fine. When I'm scrolled down a bit, the helper element seems to have an offset of the same height that I'm scrolled down which makes it impossible to see which item you originally started dragging. How do I fix this or work around the issue? If there is no fix what is a really good alternative drag-able plugin? Here are my initialization parameters for the sortable. $("#sortable").sortable( {placeholder: 'ui-state-highlight' } ); $("#sortable").disableSelection();

    Read the article

  • Helper Casting Functions -- Is it a code smell?

    - by Earlz
    I recently began to start using functions to make casting easier on my fingers for one instance I had something like this ((Dictionary<string,string>)value).Add(foo); and converted it to a tiny little helper function so I can do this ToDictionary(value).Add(foo); Is this a code smell? Also, what about simpler examples? For example in my scripting engine I've considered making things like this ((StringVariable)arg).Value="foo"; be ToStringVar(arg).Value="foo"; I really just dislike how inorder to cast a value and instantly get a property from it you must enclose it in double parentheses. I have a feeling the last one is much worse than the first one though (also I've marked this language agnostic even though my example is C#)

    Read the article

  • How to add a view helper directory (zend framework)

    - by Cédric Girard
    Hi, I begin with ZF (1.9.7), and I want to use View Helpers from a library shared between all my projects. But I can't find how to add it directory to the helpers path. My herpers works fines when I put them in application's helpers path. Here is the error, where I find the path to ZF helpers, and path to the applications ones. object(ArrayObject)#71 (3) { ["exception"]=> object(Zend_Loader_PluginLoader_Exception)#70 (6) { ["message:protected"]=> string(151) "Plugin by name 'Voo' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/;C:/ZendStd/www/applis/VOO4_PROJECTX/views\helpers/" ["string:private"]=> string(0) "" ["code:protected"]=> int(0) ["file:protected"]=> string(89) "C:\Program Files\Zend\ZendServer\share\ZendFramework\library\Zend\Loader\PluginLoader.php" ["line:protected"]=> int(401) Best regards Cédric

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >