Ruby on Rails Tuesday, September 28, 2010

Hello ROR users:
 
I would like to start a new discussion on the "Future of MySQL with Oracle"
 
I feel this issue has a critical impact on opensource developers like you & me. 
We need to explore the option of developing SQLLIte3 to the level of MySql if required.
 
Any update on "Letter to the EC opposing Oracle's acquisition of MySQL" by KEI?
 
Regards
Sharath


 
On Mon, Sep 27, 2010 at 6:39 PM, <rubyonrails-talk+noreply@googlegroups.com> wrote:

Group: http://groups.google.com/group/rubyonrails-talk/topics

    ssmithstone <stephen.smithstone@gmail.com> Sep 27 05:29AM -0700 ^
     
    Trying to make my controllers as skinny as possible , so come across a
    design issue if I want to send out an email when a model is created
    would I put this functionality on the after_create method or inside of
    the controller after the #save method

     

    Ar Chron <lists@ruby-forum.com> Sep 27 03:03PM +0200 ^
     
    If I understand the requirement, then the creation of an e-mail is the
    business of the model.
     
    Controller should be deciding "After creation of model X, what view does
    the user see? To the index view, the show view of the model just
    created, or back to the view the user was at before creating the model?"
     
    --
    Posted via http://www.ruby-forum.com/.

     

    AppleII717 <salex@mac.com> Sep 27 06:00AM -0700 ^
     
    I'm considering porting an application to RoR. The application is
    basically a "Order Entry" type system for the Interior Designer
    vertical market. The existing application has a table with over 400
    column! (not my design!). The majority of these columns are
    measurements and descriptions for a certain types of product
    categories (e.g., "Draperies","Sheer Draperies",
    "Upholstery","Pillows","Lampshades", etc)
     
    Each one of these categories (25+) has a custom form that display the
    measurement attributes for that category. To make things worse,
    there's a lot of javascript that enables/disables/shows/hides areas/
    fields. There is some sharing of attributes (width, height, length,
    size, for example). I can cut down the javascript by creating more
    categories - for instance there are 3 types of "Sheer Draperies".
     
    I alway though that these "Category Details" didn't need to be stored
    individually in a record, but serialized in a "Details" fields. Now
    the basic question is what would be the best approach?
     
    I've never done xml/xslt type forms and don't know how difficult that
    would be.
     
    I've experimented with what could be considered "Tableless STI" and it
    works, but with a few gotcha's. For instance:
     
    class Detail < ActiveRecord::Base
    def self.columns
    @columns ||= [];
    end
    ... rest of tableless stuff
    #common attributes
    column :type, :string
    column :category, :string
    column :workroom_material_reference, :text
    column :description, :string
    ....
    end
     
     
    class Carpet < Detail
    column :style, :string
    column :quanity, :integer
    column :yards, :float
    end
     
    The tableless approach would not allow me to create a new Carpet
    without first doing Detail.new. There were other problems that I
    hacked around, like defining def self.new_category(category) that
    creates new ActiveRecord objects for both the basic attributes and the
    category attributes. Maybe if I used a real table, some of those
    problems would go away.
     
    That approach is livable, but was wondering if I am totally missing a
    better approach?
     
    Anyway, I know I am still going to have a couple hundred date elements
    to deal with and a bunch of partials.
     
    Anyone want to point me in a different direction?
     
    Steve Alex

     

    Amit Tomar <lists@ruby-forum.com> Sep 27 10:00AM +0200 ^
     
    Hii All, i loaded mod_xsendfile.so in apche , i added few line in
    httpd.conf files
     
    LoadModule xsendfile_module modules/mod_xsendfile.so
     
    XSendFile on
     
    XSendFileAllowAbove on
     
    <VirtualHost * localhost:80>
    ServerName src
     
    DocumentRoot C:/InstantRails-2.0-win/rails_apps/src/public/
     
    ProxyPass / http://localhost:3000/
     
    ProxyPassReverse / http://localhost:3000/
     
    </VirtualHost >
     
    now in my rails application i have a streams controller and inside
    streams controller i have a function named download ,code for code
    download is below
     
    def download
     
    @stream = Stream.find(params[:id])
     
    filename = "#{@stream.location}"
     
    response.headers['Content-Type'] = "application/force-download"
     
    response.headers['Content-Disposition'] = "attachment;
    filename=\"#{File.basename(filename)}\""
     
    response.headers["X-Sendfile"] = @stream.location
     
    response.headers['Content-length'] = File.size(filename)
     
    render :nothing => true
     
    end
     
    Problem is my rails application still handling this request but i would
    like apache to handle this request ,can anyone tell me how i configure
    apche to handle this request??
    --
    Posted via http://www.ruby-forum.com/.

     

    Frederick Cheung <frederick.cheung@gmail.com> Sep 27 03:34AM -0700 ^
     

    > Problem is my rails application still handling this request but i would
    > like apache to handle this request ,can anyone tell me how i configure
    > apche to handle this request??
     
    So what happens when you hit that controller ? (and did you notice
    that rails' send_file method has an x_sendfile option)
     
    Fred

     

    Amit Tomar <lists@ruby-forum.com> Sep 27 01:28PM +0200 ^
     
    Frederick Cheung wrote:
     
    > So what happens when you hit that controller ? (and did you notice
    > that rails' send_file method has an x_sendfile option)
     
    > Fred
     
    Fred thanks for responding
    Actully when i downloding files,mongrel rendering things,
     
    Processing StreamsController#download (for 127.0.0.1 at 2010-09-27
    16:50:47) [GET]
    Parameters: {"id"=>"6655"}
    ?[4;36;1mSQL (0.0ms)?[0m ?[0;1mSET NAMES 'utf8'?[0m
    ?[4;35;1mSQL (0.0ms)?[0m ?[0mSET SQL_AUTO_IS_NULL=0?[0m
    ?[4;36;1mStream Columns (0.0ms)?[0m ?[0;1mSHOW FIELDS FROM
    `streams`?[0m
    ?[4;35;1mStream Load (0.0ms)?[0m ?[0mSELECT * FROM `streams` WHERE
    (`streams`.`id` = 6655) ?[0
    Completed in 78ms (View: 0, DB: 0) | 200 OK
    [http://src/streams/download/6655]
     
    It is when i am trying to download 2.2GB of file ,file is downloaded
    completely,but my worry is why mongrel is rendering things if apache is
    handling download
    --
    Posted via http://www.ruby-forum.com/.

     

    Frederick Cheung <frederick.cheung@gmail.com> Sep 27 05:29AM -0700 ^
     

    > It is when i am trying to download 2.2GB of file ,file is downloaded
    > completely,but my worry is why mongrel is rendering things if apache is
    > handling download
     
    That looks entirely normal to me - your rails code does need to be
    invoked at some point in order for it to tell apache which file to
    send.
     
    Fred

     

    Amit Tomar <lists@ruby-forum.com> Sep 27 02:36PM +0200 ^
     
    Frederick Cheung wrote:
    > invoked at some point in order for it to tell apache which file to
    > send.
     
    > Fred
     
    But Fred lot of experts are saying ,mongerl doesn't render anything
    while apche handle the request and one more thing how do i make sure
    apache is handling is request??
    --
    Posted via http://www.ruby-forum.com/.

     

    Michael Schuerig <michael@schuerig.de> Sep 27 02:52PM +0200 ^
     
    On Monday 27 September 2010, Amit Tomar wrote:
     
    > But Fred lot of experts are saying ,mongerl doesn't render anything
    > while apche handle the request and one more thing how do i make sure
    > apache is handling is request??
     
    Amir, I'm not sure, but you might be misunderstanding what xsendfile is
    for and how it works. This mechanism is not intended to serve "ordinary"
    static files located in the public directory of an application. Rather,
    it is a way for your controller to hand off serving a file to Apache
    instead of doing it from within Rails.
     
    So, your controller *has* to be involved. It's the job of the controller
    action to decide which file to return in the response and then call
    send_file with that file as a parameter. In the production environment,
    this has the effect that the Rails process does not respond with the
    file itself. Instead, Rails sets a special header which in turn is
    picked up by Apache (or nginx, lighttpd) and interpreted in such a way
    that it now serves the named file.
     
    Michael
     
    --
    Michael Schuerig
    mailto:michael@schuerig.de
    http://www.schuerig.de/michael/

     

    Sunny Ezror <lists@ruby-forum.com> Sep 27 11:10AM +0200 ^
     
    Have you tried passing in locals for the partial?
     
    Not sure how Rails 3 does it, but Rails 2 its
     
    <%=escape_javascript(render :partial =>"comments/comment", :locals =>
    {:comment => @comment))%>
     
    -sunny
    http://ezror.com
    --
    Posted via http://www.ruby-forum.com/.

     

    radhames brito <rbritom@gmail.com> Sep 27 08:45AM -0400 ^
     
    @sunny @comment does not exists inside the create action, and he needs to
    iterate over a collection , @comments
     
     
    <%=escape_javascript(render :partial =>"comments/comment", :locals =>
    {:comments =>fill the comments collection...))%>
     
     
    or
     
     
    @comment = lots of stuff going on here but it works...
    @comments = fill the comments collection..
    if @comment.save
    flash[:notice] = "Successfully created comment."
    respond_to do |format|
    format.js
    end
    end
     
    then
     
    <%=escape_javascript(render :partial =>"comments/comment", :locals =>
    {:comments => @comments))%>
     
     
    @comments does not exists inside the response from create.js.erb so you have
    to build it there or in the controller's create action before the respond_to
    block
     
     
    you can check my example
     
    http://github.com/rbritom/Simple_polymorphic_nested_comments

     

    mrpink <sonke@webperator.de> Sep 27 05:44AM -0700 ^
     
    Hi guys,
     
    can anyone explain how to show error_messages_on (like back in Rails
    2 , without Ajax) fields that didnt' pass the validation the jquery
    way.
     
    I googled for about 2 hours now and found nothing. Jquery works fine
    and adds the content to my table, but im totally stuck with the whole
    error/validation thing.
     
    My form looks like this:
     
    <%= form_for Translation.new , :remote => true do |f| %>
    <table>
    <tr>
    <td>
    <%= f.label :locale %><br />
    <%= f.text_field :locale %>
     
    </td>
    <td>
    <%= f.label :key %><br />
    <%= f.text_field :key %>
    </td>
    </tr>
    <tr>
    <td>
    <%= f.label :value %><br />
    <%= f.text_area :value , :rows => 3%>
    </td>
    <td>
    <%= f.label :interpolations %><br />
    <%= f.text_area :interpolations, :rows => 3 %>
    </td>
    </tr>
    <tr>
    <td>
    <%= f.label :is_proc %><br />
    <%= f.check_box :is_proc %>
    </td>
    <td></td>
    </tr>
    </table>
    <p><%= f.submit t('translation.create') %></p>
    <% end %>
     
    Create action like this:
    def create
    if @translation.save
    flash[:notice] = "Successfully created translation."
    respond_to do |format|
    format.html { redirect_to @translation }
    format.js
    end
    else
    respond_to do |format|
    format.html { render :action => 'new'}
    # show what went wrong with jquery
    end
    end
    end
     
    and create.js.erb
    /* Insert a notice between the last comment and the comment form */
    $("#translation-notice").html('<div class="flash notice"><%=
    escape_javascript(flash.delete(:notice)) %></div>');
     
    /* Add the new comment to the bottom of the comments list */
    $("#translations").prepend("<%=
    escape_javascript(render(@translation)) %>");
     
    /* Highlight the new comment */
    $("#translation-<%= @translation.id %>").effect("highlight", {},
    3000);
     
    /* Reset the comment form */
    $("#new_translation")[0].reset();
     
    Adding validated data works but please give me hint with error
    validation thing.
     
    thanks

     

    egervari <ken.egervari@gmail.com> Sep 26 02:43PM -0700 ^
     
    Assuming you want to stream some flv videos, what is the best way to
    secure them via authentication while also embedding them in some kind
    of web flash player?

     

    Sunny Ezror <lists@ruby-forum.com> Sep 27 11:22AM +0200 ^
     
    I'm having the same trouble with securing my videos for my latest app. A
    simple before_filter can stop the user from accessing the page, but once
    the video streams via a web player, the user can easily steal it.
     
    Only solution I can think of is to use amazon s3's url expiration, but
    that gets overly complicated.
     
    -sunny
    http://ezror.com
    --
    Posted via http://www.ruby-forum.com/.

     

    Ugis Ozols <ugis.ozolss@gmail.com> Sep 27 02:01AM -0700 ^
     
    I'm using this:
     
    :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
     

     

    "Felix Schäfer" <schaefer@cypres-it.com> Sep 27 11:51AM +0200 ^
     
    Am 26.09.2010 um 18:54 schrieb Nadal:
     
    > I am working on a rails3 project. Is there a tool to validate the
    > format of email address. It does not have to be fancy regex. Just a
    > few simple validations. However I don't want to reinvent the wheel?
     
    Using a regex to validate an email format is in most cases a bad idea, the 2 proposed regexes won't for example recognize quoted local parts, which are valid (e.g. "foo@bar"@rails.info is a valid address). There's a validate_email_format_of plugin on github[1] which works fine on rails2, I think there is a branch/fork for rails3 somewhere too. Another method would be to just drop an EmailValidator into your lib so that you can reuse it at other places in your rails app, have a look at [2] (yes, it still is a regex and only matches what the RFC refers to as "addr-spec" as opposed to a "full" address, but a not-so-bad one).
     
    Anyway, I'm a little surprised that rails3 having gone from TMail to Mail hasn't added a validator that would re-use the one already present in Mail…
     
    Regards,
     
    Felix
     
     
    [1] http://github.com/alexdunae/validates_email_format_of
    [2] http://lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true

     

    "Felix Schäfer" <schaefer@cypres-it.com> Sep 27 01:07PM +0200 ^
     
    Am 27.09.2010 um 12:57 schrieb Sunny Ezror:
     
    > Felix, I believe it does. In fact I did a quick check of both .info and
    > .me and they worked fine.
     
    The point being the localpart "foo@bar" (and yes, the quotes are part of the localpart) in "foo@bar"@rails.info, not the TLD.
     
    Oh, and you should use \A and \z (string delimiters) over ^ and $ (line delimiters), as your regex will also validate strings of the form: foo@bar.com\nSome-funky-DB-buster .
     
    Best,
     
    Felix

     

    Didde Brockman <didde@illianced.com> Sep 27 12:56PM +0200 ^
     
    Hi everyone,
     
    We're looking for an independent, driven and capable freelancer willing to help implement a small site using RoR. A CMS is required and among the candidates we like Typus the most, but can be flexible in this matter. You will be provided with complete front-end code (XHTML and CSS) as well as designs outlining the site's wireframe.
     
    Contact me directly if you think this might be interesting! We're based in Sweden, but welcome anyone from US/EU to get in touch for further details and planning.
     
    Many thanks.
     
     
    /didde
     
    --
    Didde Brockman, Illianced
    http://www.illianced.com/

     

    PalaniKannan K <kpalanikannan@gmail.com> Sep 27 10:05AM +0200 ^
     
    Dear Jeff,
     
    Thank you very much... Excellent.
     
     
    --
    With Regards
    Palani Kannan. K

     

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.



--
With Best Regards
 
Sharath
sing as if no one is listening
dance as if no one is watching
love as you've never loved before
live as if heaven is here on earth

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment