JannaB | 5 Jul 04:12
Favicon

php => rails (JSON)


I have an application that creates a snippet of php in a server, for
packaging up data for JSON, using the php package "Pear." The snippet
I create (with varying data, of course, as the application runs) is
written in php, but I really want to keep things rails-centric. Is
there a way to convert this to NOT use php, so that I am entirely Ruby
on Rails? Thanks, Janna B

<?php
ini_set('include_path',ini_get('include_path').";C:\Program Files
\Apache Group\Apache2\htdocs"."\pear");
require('JSON.php');

$records=array();
$records[]=array('order'=>1, 'username'=>'joeyt');
$json=new Services_JSON();
echo($json->encode($records));
?>

Great Kindness | 5 Jul 01:51

add a new locale using raul's translate_routes plug-in


I just started using Raul Murciano's translate_routes plug-in. It's
great. Now what I can't understand is how to add a new locale (in my
case, French). I figured that I could just add a new section to my
translation file (text.yml). I appended the following to the text.yml
file:

fr:
  back: retourner

Then in my application layout (which I copied from Raul's demo
application), I changed the code from:

<%= I18n.locale == 'es' ? link_to('en', :locale => 'en') : link_to
('es', :locale => 'es') %>

to:

<%= I18n.locale == 'fr' ? link_to('en', :locale => 'en') : link_to
('fr', :locale => 'fr') %>

When I run my application, I get this error:

No route matches {:action=>"index", :locale=>"fr"}

So, I'm guess I've got to make a change somewhere else for the
application to recognize this new route. What am I missing?

CMS action & "/cms" subfolder for each controller


How do I do this? (And is this a good solution?)

I want to have a "/cms" for each controller so I can login as admin
and edit them, instead of creating whole new controllers for the cms.

Default if you add a new action like, def cms... you have to do /
controller/1/cms.

I'm thinking of creating the backend that all links up each controller
through the "/cms"

How can I route this? and is this a good idea?
Bharat Ruparel | 4 Jul 23:52

Ajax request and redirection


This is most likely my lack of understanding of Ajax concepts, but I
cannot find an answer on the web for the following question:

"Should an ajax request triggered by a specific page must come back to
the same page?"

Here is my jQuery handler in the jsTree that communicates with my server
side Rails code:

Note that the base_url is defined at the top of this file as shown
below:

var base_url = "/folders/";
...
var handle_selected = function(docs_count_in_json)   {
    hide_progress();
    //alert(docs_count_in_json.documents_count);
    var c = docs_count_in_json.documents_count;
    if (c > 0)  {
        // alert("Has documents to display.")
        // should directly go to the documents tab if there are
documents
        var s_id =
jQuery.tree_reference('folders_tree').selected.attr('id');
        jQuery.ajax({
            type: "POST",
            url: base_url + 'set_current_folder/' + s_id,
            beforeSend: show_progress,
            data: ({authenticity_token: AUTH_TOKEN}),
(Continue reading)

JannaB | 4 Jul 23:34
Favicon

Msdd update


I must be missing something. I have a list of values returned (id's to
my 'associates'  table) and I want to update all of those in the list.
Presently, I iterate through the list, updating each one (see below).

Isn;t there a way I can do this all in one fell swoopy in RoR, without
having to iterate through the list? -Janna B.

params[:form__list1].each do |id|
          associate = Associate.find(id)
          associate.update_attributes({:channel_id =>
@channel.id, :joined_channel_datetime => DateTime.now})
end
Vikas Gholap | 4 Jul 14:37

problem for authorize.net in service merchant plugin


Hello,

I used service merchant plugin  in my application. using "paypal getway"
it works fine.

But when i tried authorize.net as a getway, it dose not work. It gives
error

StandardError in SubscriptionsController#subscribe
Recurring payment creation error: User authentication failed due to
invalid authentication values.

When i debug the code I think one file (i.e may be
authorizenet_extension.rb) is missing in

"vendor\plugins\service_merchant\recurring_billing\lib\am_extensions"

There is only paypal_extension.rb is present for paypal getway. but not
like "authorize.net_extension.rb" for authorize.net getway.

Am I right?

If the authorizenet_extension.rb is missing, please tell me whether
should I get that file.
Please guide me where I'm doing wrong?

--
--
Thanks,
(Continue reading)

Rajendra Bayana | 4 Jul 12:12

scaffolding


hi , i used the folllwing command to scaffold,

G:\my\webblog>ruby script/generate scaffold webblog id:integer
title:string body
:text created_at:datetime

after when i migrate with the follwing command

rake db:migrate

i got the error as

(in G:/my/webblog)
== 1 CreateWebblogs: migrating
================================================
-- create_table(:webblogs)
rake aborted!
Mysql::Error: You have an error in your SQL syntax; check the manual
that corres
ponds to your MySQL server version for the right syntax to use near
'(11), `titl
e` varchar(255) DEFAULT NULL, `body` text DEFAULT NULL, `created_at` '
at line 1
: CREATE TABLE `webblogs` (`id` int(11) DEFAULT NULL auto_increment
PRIMARY KEY(
11), `title` varchar(255) DEFAULT NULL, `body` text DEFAULT NULL,
`created_at` d
atetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL) ENGINE=InnoDB

(Continue reading)

Learn by Doing | 4 Jul 11:55

save! not allowed after validates_uniqueness


I have this in a model

     validates_uniqueness_of :aspect, :scope => :user_id

In an instance method of the same model I have "save!" but I don't touch
the :aspect attribute in that instance method at all.

Whenever that save! command is run however I get this error:

      ActiveRecord::RecordInvalid: Validation failed:  Aspect has
already been taken

I don't understand.  The validation should not skip the instance from
which the method is called.  Please help.  Thanks.
--

-- 
Posted via http://www.ruby-forum.com/.

Rajkumar Surabhi | 4 Jul 10:51

IOError while rendering and redirecting


HI all,

I am getting IOError while rendering view or redirecting.

If i refresh the page the actual page is displaying.

Please tell me wht is the problem and how to solve the problem.

Regards,

Raju
--

-- 
Posted via http://www.ruby-forum.com/.

Learn by Doing | 4 Jul 10:42

prevent orphan records


If I have

   belongs_to  :user

Do I need to have

   validates_presence_of   :user_id

?

Does Rails validate the presence of :user_id automatically if I have
belongs_to :user?

In other words, does Rails prevent against creating orphan records that
belong to non-existent users?

Thanks.
--

-- 
Posted via http://www.ruby-forum.com/.

Aaron Day | 4 Jul 10:25

Password needed to view atom feed


 I have a before_filter in the controller where the atom feed is coming
from. I want it to check the password when entering that area but not
when a user wants to view the rss feed. Is there a way I can use the
:except here? It's the before_filter on index that makes this happen.
--

-- 
Posted via http://www.ruby-forum.com/.


Gmane